Makefile 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191
  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 = 01
  9. SUBLEVEL =
  10. EXTRAVERSION =
  11. ifneq "$(SUBLEVEL)" ""
  12. U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
  13. else
  14. U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION)
  15. endif
  16. TIMESTAMP_FILE = include/generated/timestamp_autogenerated.h
  17. VERSION_FILE = include/generated/version_autogenerated.h
  18. HOSTARCH := $(shell uname -m | \
  19. sed -e s/i.86/x86/ \
  20. -e s/sun4u/sparc64/ \
  21. -e s/arm.*/arm/ \
  22. -e s/sa110/arm/ \
  23. -e s/ppc64/powerpc/ \
  24. -e s/ppc/powerpc/ \
  25. -e s/macppc/powerpc/\
  26. -e s/sh.*/sh/)
  27. HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
  28. sed -e 's/\(cygwin\).*/cygwin/')
  29. export HOSTARCH HOSTOS
  30. # Deal with colliding definitions from tcsh etc.
  31. VENDOR=
  32. #########################################################################
  33. # Allow for silent builds
  34. ifeq (,$(findstring s,$(MAKEFLAGS)))
  35. XECHO = echo
  36. else
  37. XECHO = :
  38. endif
  39. # *DOCUMENTATION*
  40. # To see a list of typical targets execute "make help"
  41. # More info can be located in ./README
  42. # Comments in this file are targeted only to the developer, do not
  43. # expect to learn how to build the kernel reading this file.
  44. # Do not:
  45. # o use make's built-in rules and variables
  46. # (this increases performance and avoids hard-to-debug behaviour);
  47. # o print "Entering directory ...";
  48. MAKEFLAGS += -rR --no-print-directory
  49. # Avoid funny character set dependencies
  50. unexport LC_ALL
  51. LC_COLLATE=C
  52. LC_NUMERIC=C
  53. export LC_COLLATE LC_NUMERIC
  54. # We are using a recursive build, so we need to do a little thinking
  55. # to get the ordering right.
  56. #
  57. # Most importantly: sub-Makefiles should only ever modify files in
  58. # their own directory. If in some directory we have a dependency on
  59. # a file in another dir (which doesn't happen often, but it's often
  60. # unavoidable when linking the built-in.o targets which finally
  61. # turn into vmlinux), we will call a sub make in that other dir, and
  62. # after that we are sure that everything which is in that other dir
  63. # is now up to date.
  64. #
  65. # The only cases where we need to modify files which have global
  66. # effects are thus separated out and done before the recursive
  67. # descending is started. They are now explicitly listed as the
  68. # prepare rule.
  69. # To put more focus on warnings, be less verbose as default
  70. # Use 'make V=1' to see the full commands
  71. ifeq ("$(origin V)", "command line")
  72. KBUILD_VERBOSE = $(V)
  73. endif
  74. ifndef KBUILD_VERBOSE
  75. KBUILD_VERBOSE = 0
  76. endif
  77. # Call a source code checker (by default, "sparse") as part of the
  78. # C compilation.
  79. #
  80. # Use 'make C=1' to enable checking of only re-compiled files.
  81. # Use 'make C=2' to enable checking of *all* source files, regardless
  82. # of whether they are re-compiled or not.
  83. #
  84. # See the file "Documentation/sparse.txt" for more details, including
  85. # where to get the "sparse" utility.
  86. ifeq ("$(origin C)", "command line")
  87. KBUILD_CHECKSRC = $(C)
  88. endif
  89. ifndef KBUILD_CHECKSRC
  90. KBUILD_CHECKSRC = 0
  91. endif
  92. # Use make M=dir to specify directory of external module to build
  93. # Old syntax make ... SUBDIRS=$PWD is still supported
  94. # Setting the environment variable KBUILD_EXTMOD take precedence
  95. ifdef SUBDIRS
  96. KBUILD_EXTMOD ?= $(SUBDIRS)
  97. endif
  98. ifeq ("$(origin M)", "command line")
  99. KBUILD_EXTMOD := $(M)
  100. endif
  101. # kbuild supports saving output files in a separate directory.
  102. # To locate output files in a separate directory two syntaxes are supported.
  103. # In both cases the working directory must be the root of the kernel src.
  104. # 1) O=
  105. # Use "make O=dir/to/store/output/files/"
  106. #
  107. # 2) Set KBUILD_OUTPUT
  108. # Set the environment variable KBUILD_OUTPUT to point to the directory
  109. # where the output files shall be placed.
  110. # export KBUILD_OUTPUT=dir/to/store/output/files/
  111. # make
  112. #
  113. # The O= assignment takes precedence over the KBUILD_OUTPUT environment
  114. # variable.
  115. # KBUILD_SRC is set on invocation of make in OBJ directory
  116. # KBUILD_SRC is not intended to be used by the regular user (for now)
  117. ifeq ($(KBUILD_SRC),)
  118. # OK, Make called in directory where kernel src resides
  119. # Do we want to locate output files in a separate directory?
  120. ifeq ("$(origin O)", "command line")
  121. KBUILD_OUTPUT := $(O)
  122. endif
  123. ifeq ("$(origin W)", "command line")
  124. export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
  125. endif
  126. # That's our default target when none is given on the command line
  127. PHONY := _all
  128. _all:
  129. # Cancel implicit rules on top Makefile
  130. $(CURDIR)/Makefile Makefile: ;
  131. ifneq ($(KBUILD_OUTPUT),)
  132. # Invoke a second make in the output directory, passing relevant variables
  133. # check that the output directory actually exists
  134. saved-output := $(KBUILD_OUTPUT)
  135. KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
  136. $(if $(KBUILD_OUTPUT),, \
  137. $(error output directory "$(saved-output)" does not exist))
  138. PHONY += $(MAKECMDGOALS) sub-make
  139. $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
  140. @:
  141. sub-make: FORCE
  142. $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
  143. KBUILD_SRC=$(CURDIR) \
  144. KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
  145. $(filter-out _all sub-make,$(MAKECMDGOALS))
  146. # Leave processing to above invocation of make
  147. skip-makefile := 1
  148. endif # ifneq ($(KBUILD_OUTPUT),)
  149. endif # ifeq ($(KBUILD_SRC),)
  150. # We process the rest of the Makefile if this is the final invocation of make
  151. ifeq ($(skip-makefile),)
  152. # If building an external module we do not care about the all: rule
  153. # but instead _all depend on modules
  154. PHONY += all
  155. ifeq ($(KBUILD_EXTMOD),)
  156. _all: all
  157. else
  158. _all: modules
  159. endif
  160. srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR))
  161. objtree := $(CURDIR)
  162. src := $(srctree)
  163. obj := $(objtree)
  164. VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
  165. export srctree objtree VPATH
  166. OBJTREE := $(objtree)
  167. SPLTREE := $(OBJTREE)/spl
  168. TPLTREE := $(OBJTREE)/tpl
  169. SRCTREE := $(srctree)
  170. TOPDIR := $(SRCTREE)
  171. export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
  172. MKCONFIG := $(SRCTREE)/mkconfig
  173. export MKCONFIG
  174. # Make sure CDPATH settings don't interfere
  175. unexport CDPATH
  176. #########################################################################
  177. # The "tools" are needed early, so put this first
  178. # Don't include stuff already done in $(LIBS)
  179. # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
  180. # is "yes"), so compile examples after U-Boot is compiled.
  181. SUBDIR_TOOLS = tools
  182. SUBDIRS = $(SUBDIR_TOOLS)
  183. .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
  184. ifeq (include/config.mk,$(wildcard include/config.mk))
  185. # Include autoconf.mk before config.mk so that the config options are available
  186. # to all top level build files. We need the dummy all: target to prevent the
  187. # dependency target in autoconf.mk.dep from being the default.
  188. all:
  189. sinclude include/autoconf.mk.dep
  190. sinclude include/autoconf.mk
  191. SUBDIR_EXAMPLES-y := examples/standalone
  192. SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
  193. ifndef CONFIG_SANDBOX
  194. SUBDIRS += $(SUBDIR_EXAMPLES-y)
  195. endif
  196. # load ARCH, BOARD, and CPU configuration
  197. include include/config.mk
  198. export ARCH CPU BOARD VENDOR SOC
  199. # set default to nothing for native builds
  200. ifeq ($(HOSTARCH),$(ARCH))
  201. CROSS_COMPILE ?=
  202. endif
  203. # SHELL used by kbuild
  204. CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  205. else if [ -x /bin/bash ]; then echo /bin/bash; \
  206. else echo sh; fi ; fi)
  207. HOSTCC = gcc
  208. HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
  209. ifeq ($(HOSTOS),cygwin)
  210. HOSTCFLAGS += -ansi
  211. endif
  212. # Mac OS X / Darwin's C preprocessor is Apple specific. It
  213. # generates numerous errors and warnings. We want to bypass it
  214. # and use GNU C's cpp. To do this we pass the -traditional-cpp
  215. # option to the compiler. Note that the -traditional-cpp flag
  216. # DOES NOT have the same semantics as GNU C's flag, all it does
  217. # is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
  218. #
  219. # Apple's linker is similar, thanks to the new 2 stage linking
  220. # multiple symbol definitions are treated as errors, hence the
  221. # -multiply_defined suppress option to turn off this error.
  222. #
  223. ifeq ($(HOSTOS),darwin)
  224. # get major and minor product version (e.g. '10' and '6' for Snow Leopard)
  225. DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')
  226. DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')
  227. os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
  228. $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
  229. # Snow Leopards build environment has no longer restrictions as described above
  230. HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")
  231. HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")
  232. HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
  233. endif
  234. # Decide whether to build built-in, modular, or both.
  235. # Normally, just do built-in.
  236. KBUILD_MODULES :=
  237. KBUILD_BUILTIN := 1
  238. # If we have only "make modules", don't compile built-in objects.
  239. # When we're building modules with modversions, we need to consider
  240. # the built-in objects during the descend as well, in order to
  241. # make sure the checksums are up to date before we record them.
  242. ifeq ($(MAKECMDGOALS),modules)
  243. KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
  244. endif
  245. # If we have "make <whatever> modules", compile modules
  246. # in addition to whatever we do anyway.
  247. # Just "make" or "make all" shall build modules as well
  248. # U-Boot does not need modules
  249. #ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
  250. # KBUILD_MODULES := 1
  251. #endif
  252. #ifeq ($(MAKECMDGOALS),)
  253. # KBUILD_MODULES := 1
  254. #endif
  255. export KBUILD_MODULES KBUILD_BUILTIN
  256. export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
  257. # Beautify output
  258. # ---------------------------------------------------------------------------
  259. #
  260. # Normally, we echo the whole command before executing it. By making
  261. # that echo $($(quiet)$(cmd)), we now have the possibility to set
  262. # $(quiet) to choose other forms of output instead, e.g.
  263. #
  264. # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
  265. # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
  266. #
  267. # If $(quiet) is empty, the whole command will be printed.
  268. # If it is set to "quiet_", only the short version will be printed.
  269. # If it is set to "silent_", nothing will be printed at all, since
  270. # the variable $(silent_cmd_cc_o_c) doesn't exist.
  271. #
  272. # A simple variant is to prefix commands with $(Q) - that's useful
  273. # for commands that shall be hidden in non-verbose mode.
  274. #
  275. # $(Q)ln $@ :<
  276. #
  277. # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
  278. # If KBUILD_VERBOSE equals 1 then the above command is displayed.
  279. ifeq ($(KBUILD_VERBOSE),1)
  280. quiet =
  281. Q =
  282. else
  283. quiet=quiet_
  284. Q = @
  285. endif
  286. # If the user is running make -s (silent mode), suppress echoing of
  287. # commands
  288. ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
  289. quiet=silent_
  290. endif
  291. export quiet Q KBUILD_VERBOSE
  292. # Look for make include files relative to root of kernel src
  293. MAKEFLAGS += --include-dir=$(srctree)
  294. # We need some generic definitions (do not try to remake the file).
  295. $(srctree)/scripts/Kbuild.include: ;
  296. include $(srctree)/scripts/Kbuild.include
  297. # Make variables (CC, etc...)
  298. AS = $(CROSS_COMPILE)as
  299. # Always use GNU ld
  300. ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
  301. LD = $(CROSS_COMPILE)ld.bfd
  302. else
  303. LD = $(CROSS_COMPILE)ld
  304. endif
  305. CC = $(CROSS_COMPILE)gcc
  306. CPP = $(CC) -E
  307. AR = $(CROSS_COMPILE)ar
  308. NM = $(CROSS_COMPILE)nm
  309. LDR = $(CROSS_COMPILE)ldr
  310. STRIP = $(CROSS_COMPILE)strip
  311. OBJCOPY = $(CROSS_COMPILE)objcopy
  312. OBJDUMP = $(CROSS_COMPILE)objdump
  313. AWK = awk
  314. RANLIB = $(CROSS_COMPILE)RANLIB
  315. DTC = dtc
  316. CHECK = sparse
  317. CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
  318. -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
  319. # Use UBOOTINCLUDE when you must reference the include/ directory.
  320. # Needed to be compatible with the O= option
  321. UBOOTINCLUDE :=
  322. ifneq ($(OBJTREE),$(SRCTREE))
  323. UBOOTINCLUDE += -I$(OBJTREE)/include
  324. endif
  325. UBOOTINCLUDE += -I$(srctree)/include \
  326. -I$(srctree)/arch/$(ARCH)/include
  327. KBUILD_CPPFLAGS := -D__KERNEL__
  328. KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
  329. -Wno-format-security \
  330. -fno-builtin -ffreestanding
  331. KBUILD_AFLAGS := -D__ASSEMBLY__
  332. export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
  333. export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
  334. export MAKE AWK
  335. export DTC CHECK CHECKFLAGS
  336. export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
  337. export KBUILD_CFLAGS KBUILD_AFLAGS
  338. # When compiling out-of-tree modules, put MODVERDIR in the module
  339. # tree rather than in the kernel tree. The kernel tree might
  340. # even be read-only.
  341. export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
  342. # Files to ignore in find ... statements
  343. RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
  344. -o -name .pc -o -name .hg -o -name .git \) -prune -o
  345. export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
  346. --exclude CVS --exclude .pc --exclude .hg --exclude .git
  347. # ===========================================================================
  348. # Rules shared between *config targets and build targets
  349. # Basic helpers built in scripts/
  350. PHONY += scripts_basic
  351. scripts_basic:
  352. $(Q)$(MAKE) $(build)=scripts/basic
  353. $(Q)rm -f .tmp_quiet_recordmcount
  354. # To avoid any implicit rule to kick in, define an empty command.
  355. scripts/basic/%: scripts_basic ;
  356. KBUILD_CFLAGS += -Os #-fomit-frame-pointer
  357. ifdef BUILD_TAG
  358. KBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'
  359. endif
  360. KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
  361. KBUILD_CFLAGS += -g
  362. # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
  363. # option to the assembler.
  364. KBUILD_AFLAGS += -g
  365. NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
  366. CHECKFLAGS += $(NOSTDINC_FLAGS)
  367. # Report stack usage if supported
  368. KBUILD_CFLAGS += $(call cc-option,-fstack-usage)
  369. KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
  370. # turn jbsr into jsr for m68k
  371. ifeq ($(ARCH),m68k)
  372. ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
  373. KBUILD_AFLAGS += -Wa,-gstabs,-S
  374. endif
  375. endif
  376. # load other configuration
  377. include $(TOPDIR)/config.mk
  378. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  379. KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
  380. endif
  381. export CONFIG_SYS_TEXT_BASE
  382. LDFLAGS_u-boot += -T u-boot.lds $(LDFLAGS_FINAL)
  383. ifneq ($(CONFIG_SYS_TEXT_BASE),)
  384. LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
  385. endif
  386. # Targets which don't build the source code
  387. NON_BUILD_TARGETS = backup clean clobber distclean mrproper tidy unconfig %_config
  388. # Only do the generic board check when actually building, not configuring
  389. ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
  390. ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
  391. ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
  392. CHECK_GENERIC_BOARD = $(error Your architecture does not support generic board. \
  393. Please undefined CONFIG_SYS_GENERIC_BOARD in your board config file)
  394. endif
  395. endif
  396. endif
  397. # FIX ME
  398. cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
  399. c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
  400. # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
  401. # that (or fail if absent). Otherwise, search for a linker script in a
  402. # standard location.
  403. LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
  404. ifndef LDSCRIPT
  405. #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
  406. ifdef CONFIG_SYS_LDSCRIPT
  407. # need to strip off double quotes
  408. LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%)
  409. endif
  410. endif
  411. # If there is no specified link script, we look in a number of places for it
  412. ifndef LDSCRIPT
  413. ifeq ($(CONFIG_NAND_U_BOOT),y)
  414. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
  415. ifeq ($(wildcard $(LDSCRIPT)),)
  416. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
  417. endif
  418. endif
  419. ifeq ($(wildcard $(LDSCRIPT)),)
  420. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  421. endif
  422. ifeq ($(wildcard $(LDSCRIPT)),)
  423. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
  424. endif
  425. ifeq ($(wildcard $(LDSCRIPT)),)
  426. LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
  427. # We don't expect a Makefile here
  428. LDSCRIPT_MAKEFILE_DIR =
  429. endif
  430. ifeq ($(wildcard $(LDSCRIPT)),)
  431. $(error could not find linker script)
  432. endif
  433. endif
  434. #########################################################################
  435. # U-Boot objects....order is important (i.e. start must be first)
  436. head-y := $(CPUDIR)/start.o
  437. head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
  438. head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
  439. OBJS := $(head-y)
  440. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
  441. LIBS-y += lib/
  442. LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  443. LIBS-y += $(CPUDIR)/
  444. ifdef SOC
  445. LIBS-y += $(CPUDIR)/$(SOC)/
  446. endif
  447. LIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
  448. LIBS-$(CONFIG_OF_EMBED) += dts/
  449. LIBS-y += arch/$(ARCH)/lib/
  450. LIBS-y += fs/
  451. LIBS-y += net/
  452. LIBS-y += disk/
  453. LIBS-y += drivers/
  454. LIBS-y += drivers/dma/
  455. LIBS-y += drivers/gpio/
  456. LIBS-y += drivers/i2c/
  457. LIBS-y += drivers/input/
  458. LIBS-y += drivers/mmc/
  459. LIBS-y += drivers/mtd/
  460. LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
  461. LIBS-y += drivers/mtd/onenand/
  462. LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
  463. LIBS-y += drivers/mtd/spi/
  464. LIBS-y += drivers/net/
  465. LIBS-y += drivers/net/phy/
  466. LIBS-y += drivers/pci/
  467. LIBS-y += drivers/power/ \
  468. drivers/power/fuel_gauge/ \
  469. drivers/power/mfd/ \
  470. drivers/power/pmic/ \
  471. drivers/power/battery/
  472. LIBS-y += drivers/spi/
  473. LIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/
  474. LIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
  475. LIBS-y += drivers/serial/
  476. LIBS-y += drivers/usb/eth/
  477. LIBS-y += drivers/usb/gadget/
  478. LIBS-y += drivers/usb/host/
  479. LIBS-y += drivers/usb/musb/
  480. LIBS-y += drivers/usb/musb-new/
  481. LIBS-y += drivers/usb/phy/
  482. LIBS-y += drivers/usb/ulpi/
  483. LIBS-y += common/
  484. LIBS-y += lib/libfdt/
  485. LIBS-$(CONFIG_API) += api/
  486. LIBS-$(CONFIG_HAS_POST) += post/
  487. LIBS-y += test/
  488. ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
  489. LIBS-y += arch/$(ARCH)/imx-common/
  490. endif
  491. LIBS-$(CONFIG_ARM) += arch/arm/cpu/
  492. LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
  493. LIBS-y += board/$(BOARDDIR)/
  494. LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
  495. LIBS := $(sort $(LIBS-y))
  496. .PHONY : $(LIBS)
  497. # Add GCC lib
  498. ifdef USE_PRIVATE_LIBGCC
  499. ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
  500. PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/lib.a
  501. else
  502. PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
  503. endif
  504. else
  505. PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
  506. endif
  507. PLATFORM_LIBS += $(PLATFORM_LIBGCC)
  508. export PLATFORM_LIBS
  509. # Special flags for CPP when processing the linker script.
  510. # Pass the version down so we can handle backwards compatibility
  511. # on the fly.
  512. LDPPFLAGS += \
  513. -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  514. -DCPUDIR=$(CPUDIR) \
  515. $(shell $(LD) --version | \
  516. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  517. #########################################################################
  518. #########################################################################
  519. ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
  520. BOARD_SIZE_CHECK = \
  521. @actual=`wc -c $@ | awk '{print $$1}'`; \
  522. limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
  523. if test $$actual -gt $$limit; then \
  524. echo "$@ exceeds file size limit:" >&2 ; \
  525. echo " limit: $$limit bytes" >&2 ; \
  526. echo " actual: $$actual bytes" >&2 ; \
  527. echo " excess: $$((actual - limit)) bytes" >&2; \
  528. exit 1; \
  529. fi
  530. else
  531. BOARD_SIZE_CHECK =
  532. endif
  533. # Statically apply RELA-style relocations (currently arm64 only)
  534. ifneq ($(CONFIG_STATIC_RELA),)
  535. # $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base
  536. DO_STATIC_RELA = \
  537. start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \
  538. end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \
  539. tools/relocate-rela $(2) $(3) $$start $$end
  540. else
  541. DO_STATIC_RELA =
  542. endif
  543. # Always append ALL so that arch config.mk's can add custom ones
  544. ALL-y += u-boot.srec u-boot.bin System.map
  545. ALL-$(CONFIG_NAND_U_BOOT) += u-boot-nand.bin
  546. ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
  547. ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
  548. ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
  549. ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
  550. ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
  551. ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin
  552. ifneq ($(CONFIG_SPL_TARGET),)
  553. ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
  554. endif
  555. ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
  556. # enable combined SPL/u-boot/dtb rules for tegra
  557. ifneq ($(CONFIG_TEGRA),)
  558. ifeq ($(CONFIG_SPL),y)
  559. ifeq ($(CONFIG_OF_SEPARATE),y)
  560. ALL-y += u-boot-dtb-tegra.bin
  561. else
  562. ALL-y += u-boot-nodtb-tegra.bin
  563. endif
  564. endif
  565. endif
  566. all: $(ALL-y) $(SUBDIR_EXAMPLES-y)
  567. u-boot.dtb: checkdtc u-boot
  568. $(MAKE) $(build)=dts binary
  569. mv dts/dt.dtb $@
  570. u-boot-dtb.bin: u-boot.bin u-boot.dtb
  571. cat $^ >$@
  572. u-boot.hex: u-boot
  573. $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
  574. u-boot.srec: u-boot
  575. $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
  576. u-boot.bin: u-boot
  577. $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
  578. $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE))
  579. $(BOARD_SIZE_CHECK)
  580. u-boot.ldr: u-boot
  581. $(CREATE_LDR_ENV)
  582. $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
  583. $(BOARD_SIZE_CHECK)
  584. u-boot.ldr.hex: u-boot.ldr
  585. $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
  586. u-boot.ldr.srec: u-boot.ldr
  587. $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
  588. #
  589. # U-Boot entry point, needed for booting of full-blown U-Boot
  590. # from the SPL U-Boot version.
  591. #
  592. ifndef CONFIG_SYS_UBOOT_START
  593. CONFIG_SYS_UBOOT_START := 0
  594. endif
  595. u-boot.img: u-boot.bin
  596. tools/mkimage -A $(ARCH) -T firmware -C none \
  597. -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
  598. -e $(CONFIG_SYS_UBOOT_START) \
  599. -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
  600. sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
  601. -d $< $@
  602. u-boot.imx: u-boot.bin depend
  603. $(MAKE) $(build)=arch/arm/imx-common $(objtree)/u-boot.imx
  604. u-boot.kwb: u-boot.bin
  605. tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
  606. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
  607. u-boot.pbl: u-boot.bin
  608. tools/mkimage -n $(CONFIG_SYS_FSL_PBL_RCW) \
  609. -R $(CONFIG_SYS_FSL_PBL_PBI) -T pblimage \
  610. -d $< $@
  611. u-boot.sha1: u-boot.bin
  612. tools/ubsha1 u-boot.bin
  613. u-boot.dis: u-boot
  614. $(OBJDUMP) -d $< > $@
  615. # $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,
  616. # $(4) is pad-to
  617. SPL_PAD_APPEND = \
  618. $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \
  619. $(1) $(3); \
  620. cat $(3) $(2) > $@; \
  621. rm $(3)
  622. ifdef CONFIG_TPL
  623. SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
  624. else
  625. SPL_PAYLOAD := u-boot.bin
  626. endif
  627. u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD)
  628. $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))
  629. tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin
  630. $(call SPL_PAD_APPEND,$<,u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
  631. u-boot-with-spl.imx: spl/u-boot-spl.bin u-boot.bin
  632. $(MAKE) $(build)=arch/arm/imx-common \
  633. $(OBJTREE)/u-boot-with-spl.imx
  634. u-boot-with-nand-spl.imx: spl/u-boot-spl.bin u-boot.bin
  635. $(MAKE) $(build)=arch/arm/imx-common \
  636. $(OBJTREE)/u-boot-with-nand-spl.imx
  637. u-boot.ubl: u-boot-with-spl.bin
  638. tools/mkimage -n $(UBL_CONFIG) -T ublimage \
  639. -e $(CONFIG_SYS_TEXT_BASE) -d $< u-boot.ubl
  640. u-boot.ais: spl/u-boot-spl.bin u-boot.img
  641. tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
  642. -T aisimage \
  643. -e $(CONFIG_SPL_TEXT_BASE) \
  644. -d spl/u-boot-spl.bin \
  645. spl/u-boot-spl.ais
  646. $(OBJCOPY) ${OBJCFLAGS} -I binary \
  647. --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
  648. spl/u-boot-spl.ais spl/u-boot-spl-pad.ais
  649. cat spl/u-boot-spl-pad.ais u-boot.img > u-boot.ais
  650. u-boot.sb: u-boot.bin spl/u-boot-spl.bin
  651. $(MAKE) $(build)=$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
  652. # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
  653. # Both images are created using mkimage (crc etc), so that the ROM
  654. # bootloader can check its integrity. Padding needs to be done to the
  655. # SPL image (with mkimage header) and not the binary. Otherwise the resulting image
  656. # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
  657. # The resulting image containing both U-Boot images is called u-boot.spr
  658. u-boot.spr: u-boot.img spl/u-boot-spl.bin
  659. tools/mkimage -A $(ARCH) -T firmware -C none \
  660. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
  661. -d spl/u-boot-spl.bin $@
  662. $(OBJCOPY) -I binary -O binary \
  663. --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff $@
  664. cat u-boot.img >> $@
  665. ifneq ($(CONFIG_TEGRA),)
  666. u-boot-nodtb-tegra.bin: spl/u-boot-spl.bin u-boot.bin
  667. $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary spl/u-boot-spl spl/u-boot-spl-pad.bin
  668. cat spl/u-boot-spl-pad.bin u-boot.bin > $@
  669. rm spl/u-boot-spl-pad.bin
  670. ifeq ($(CONFIG_OF_SEPARATE),y)
  671. u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin u-boot.dtb
  672. cat u-boot-nodtb-tegra.bin u-boot.dtb > $@
  673. endif
  674. endif
  675. u-boot-img.bin: spl/u-boot-spl.bin u-boot.img
  676. cat spl/u-boot-spl.bin u-boot.img > $@
  677. # PPC4xx needs the SPL at the end of the image, since the reset vector
  678. # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
  679. # and need to introduce a new build target with the full blown U-Boot
  680. # at the start padded up to the start of the SPL image. And then concat
  681. # the SPL image to the end.
  682. u-boot-img-spl-at-end.bin: spl/u-boot-spl.bin u-boot.img
  683. $(OBJCOPY) -I binary -O binary --pad-to=$(CONFIG_UBOOT_PAD_TO) \
  684. --gap-fill=0xff u-boot.img $@
  685. cat spl/u-boot-spl.bin >> $@
  686. # Create a new ELF from a raw binary file. This is useful for arm64
  687. # where static relocation needs to be performed on the raw binary,
  688. # but certain simulators only accept an ELF file (but don't do the
  689. # relocation).
  690. # FIXME refactor dts/Makefile to share target/arch detection
  691. u-boot.elf: u-boot.bin
  692. @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \
  693. $< u-boot-elf.o
  694. @$(LD) u-boot-elf.o -o $@ \
  695. --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \
  696. -Ttext=$(CONFIG_SYS_TEXT_BASE)
  697. ifeq ($(CONFIG_SANDBOX),y)
  698. GEN_UBOOT = \
  699. $(CC) $(SYMS) -T u-boot.lds \
  700. -Wl,--start-group $(LIBS) -Wl,--end-group \
  701. $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
  702. else
  703. GEN_UBOOT = \
  704. $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
  705. $(OBJS) \
  706. --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
  707. -Map u-boot.map -o u-boot
  708. endif
  709. u-boot: depend $(SUBDIR_TOOLS) $(OBJS) $(LIBS) u-boot.lds
  710. $(GEN_UBOOT)
  711. ifeq ($(CONFIG_KALLSYMS),y)
  712. smap=`$(call SYSTEM_MAP,u-boot) | \
  713. awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
  714. $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
  715. -c $(srctree)/common/system_map.c -o common/system_map.o
  716. $(GEN_UBOOT) common/system_map.o
  717. endif
  718. $(OBJS):
  719. @:
  720. $(LIBS): depend $(SUBDIR_TOOLS) scripts_basic
  721. $(Q)$(MAKE) $(build)=$(patsubst %/,%,$(dir $@))
  722. $(SUBDIRS): depend scripts_basic
  723. $(Q)$(MAKE) $(build)=$@
  724. $(SUBDIR_EXAMPLES-y): u-boot
  725. u-boot.lds: $(LDSCRIPT) depend
  726. $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
  727. nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend scripts_basic
  728. $(MAKE) $(build)=nand_spl/board/$(BOARDDIR) all
  729. u-boot-nand.bin: nand_spl u-boot.bin
  730. cat nand_spl/u-boot-spl-16k.bin u-boot.bin > u-boot-nand.bin
  731. spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend scripts_basic
  732. $(MAKE) obj=spl -f $(srctree)/spl/Makefile all
  733. tpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend scripts_basic
  734. $(MAKE) obj=tpl -f $(srctree)/spl/Makefile all CONFIG_TPL_BUILD=y
  735. # Explicitly make _depend in subdirs containing multiple targets to prevent
  736. # parallel sub-makes creating .depend files simultaneously.
  737. depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \
  738. include/spl-autoconf.mk \
  739. include/tpl-autoconf.mk \
  740. include/autoconf.mk \
  741. include/generated/generic-asm-offsets.h \
  742. include/generated/asm-offsets.h
  743. TAG_SUBDIRS = $(SUBDIRS)
  744. TAG_SUBDIRS += $(dir $(LIBS))
  745. TAG_SUBDIRS += include
  746. FIND := find
  747. FINDFLAGS := -L
  748. checkstack:
  749. $(CROSS_COMPILE)objdump -d u-boot \
  750. `$(FIND) . -name u-boot-spl -print` | \
  751. perl $(src)/scripts/checkstack.pl $(ARCH)
  752. tags ctags:
  753. ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  754. -name '*.[chS]' -print`
  755. etags:
  756. etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  757. -name '*.[chS]' -print`
  758. cscope:
  759. $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
  760. cscope.files
  761. cscope -b -q -k
  762. SYSTEM_MAP = \
  763. $(NM) $1 | \
  764. grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
  765. LC_ALL=C sort
  766. System.map: u-boot
  767. @$(call SYSTEM_MAP,$<) > $@
  768. checkthumb:
  769. @if test $(call cc-version) -lt 0404; then \
  770. echo -n '*** Your GCC does not produce working '; \
  771. echo 'binaries in THUMB mode.'; \
  772. echo '*** Your board is configured for THUMB mode.'; \
  773. false; \
  774. fi
  775. # GCC 3.x is reported to have problems generating the type of relocation
  776. # that U-Boot wants.
  777. # See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html
  778. checkgcc4:
  779. @if test $(call cc-version) -lt 0400; then \
  780. echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \
  781. false; \
  782. fi
  783. checkdtc:
  784. @if test $(call dtc-version) -lt 0104; then \
  785. echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
  786. false; \
  787. fi
  788. #
  789. # Auto-generate the autoconf.mk file (which is included by all makefiles)
  790. #
  791. # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
  792. # the dep file is only include in this top level makefile to determine when
  793. # to regenerate the autoconf.mk file.
  794. include/autoconf.mk.dep: include/config.h include/common.h
  795. @$(XECHO) Generating $@ ; \
  796. : Generate the dependancies ; \
  797. $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \
  798. -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || \
  799. rm $@
  800. include/autoconf.mk: include/config.h
  801. @$(XECHO) Generating $@ ; \
  802. : Extract the config macros ; \
  803. $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
  804. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
  805. rm $@.tmp
  806. # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
  807. include/tpl-autoconf.mk: include/config.h
  808. @$(XECHO) Generating $@ ; \
  809. : Extract the config macros ; \
  810. $(CPP) $(c_flags) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\
  811. -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
  812. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
  813. rm $@.tmp
  814. include/spl-autoconf.mk: include/config.h
  815. @$(XECHO) Generating $@ ; \
  816. : Extract the config macros ; \
  817. $(CPP) $(c_flags) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
  818. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
  819. rm $@.tmp
  820. include/generated/generic-asm-offsets.h: lib/asm-offsets.s
  821. @$(XECHO) Generating $@
  822. $(srctree)/tools/scripts/make-asm-offsets lib/asm-offsets.s $@
  823. lib/asm-offsets.s: include/config.h $(srctree)/lib/asm-offsets.c
  824. @mkdir -p lib
  825. $(CC) -DDO_DEPS_ONLY \
  826. $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
  827. -o $@ $(srctree)/lib/asm-offsets.c -c -S
  828. include/generated/asm-offsets.h: $(CPUDIR)/$(SOC)/asm-offsets.s
  829. @$(XECHO) Generating $@
  830. $(srctree)/tools/scripts/make-asm-offsets $(CPUDIR)/$(SOC)/asm-offsets.s $@
  831. $(CPUDIR)/$(SOC)/asm-offsets.s: include/config.h
  832. @mkdir -p $(CPUDIR)/$(SOC)
  833. if [ -f $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
  834. $(CC) -DDO_DEPS_ONLY \
  835. $(c_flags) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
  836. -o $@ $(srctree)/$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
  837. else \
  838. touch $@; \
  839. fi
  840. #########################################################################
  841. else # !config.mk
  842. all u-boot.hex u-boot.srec u-boot.bin \
  843. u-boot.img u-boot.dis u-boot \
  844. $(filter-out tools,$(SUBDIRS)) \
  845. depend dep tags ctags etags cscope System.map:
  846. @echo "System not configured - see README" >&2
  847. @ exit 1
  848. tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
  849. $(MAKE) $(build)=$@ all
  850. endif # config.mk
  851. # ARM relocations should all be R_ARM_RELATIVE (32-bit) or
  852. # R_AARCH64_RELATIVE (64-bit).
  853. checkarmreloc: u-boot
  854. @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \
  855. grep R_A | sort -u`"; \
  856. if test "$$RELOC" != "R_ARM_RELATIVE" -a \
  857. "$$RELOC" != "R_AARCH64_RELATIVE"; then \
  858. echo "$< contains unexpected relocations: $$RELOC"; \
  859. false; \
  860. fi
  861. $(VERSION_FILE):
  862. @mkdir -p $(dir $(VERSION_FILE))
  863. @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
  864. printf '#define PLAIN_VERSION "%s%s"\n' \
  865. "$(U_BOOT_VERSION)" "$${localvers}" ; \
  866. printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
  867. "$(U_BOOT_VERSION)" "$${localvers}" ; \
  868. ) > $@.tmp
  869. @( printf '#define CC_VERSION_STRING "%s"\n' \
  870. '$(shell $(CC) --version | head -n 1)' )>> $@.tmp
  871. @( printf '#define LD_VERSION_STRING "%s"\n' \
  872. '$(shell $(LD) -v | head -n 1)' )>> $@.tmp
  873. @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
  874. $(TIMESTAMP_FILE):
  875. @mkdir -p $(dir $(TIMESTAMP_FILE))
  876. @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
  877. @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
  878. @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
  879. easylogo env gdb:
  880. $(Q)$(MAKE) $(build)=tools/$@ MTD_VERSION=${MTD_VERSION}
  881. gdbtools: gdb
  882. xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
  883. $(Q)$(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) $(build)=doc/DocBook $@
  884. tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
  885. $(Q)$(MAKE) $(build)=tools HOST_TOOLS_ALL=y
  886. .PHONY : CHANGELOG
  887. CHANGELOG:
  888. git log --no-merges U-Boot-1_1_5.. | \
  889. unexpand -a | sed -e 's/\s\s*$$//' > $@
  890. include/license.h: tools/bin2header COPYING
  891. cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
  892. #########################################################################
  893. unconfig:
  894. @rm -f include/config.h include/config.mk \
  895. board/*/config.tmp board/*/*/config.tmp \
  896. include/autoconf.mk include/autoconf.mk.dep \
  897. include/spl-autoconf.mk \
  898. include/tpl-autoconf.mk
  899. %_config:: unconfig
  900. @$(MKCONFIG) -A $(@:_config=)
  901. #########################################################################
  902. clean:
  903. @rm -f examples/standalone/atmel_df_pow2 \
  904. examples/standalone/hello_world \
  905. examples/standalone/interrupt \
  906. examples/standalone/mem_to_mem_idma2intr \
  907. examples/standalone/sched \
  908. $(addprefix examples/standalone/, smc91111_eeprom smc911x_eeprom) \
  909. examples/standalone/test_burst \
  910. examples/standalone/timer
  911. @rm -f $(addprefix examples/api/, demo demo.bin)
  912. @rm -f tools/bmp_logo tools/easylogo/easylogo \
  913. tools/env/fw_printenv \
  914. tools/envcrc \
  915. $(addprefix tools/gdb/, gdbcont gdbsend) \
  916. tools/gen_eth_addr tools/img2srec \
  917. tools/dumpimage \
  918. $(addprefix tools/, mkenvimage mkimage) \
  919. tools/mpc86x_clk \
  920. $(addprefix tools/, mk$(BOARD)spl mkexynosspl) \
  921. tools/mxsboot \
  922. tools/ncb tools/ubsha1 \
  923. tools/kernel-doc/docproc \
  924. tools/proftool
  925. @rm -f $(addprefix board/cray/L1/, bootscript.c bootscript.image) \
  926. board/matrix_vision/*/bootscript.img \
  927. spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl \
  928. u-boot.lds \
  929. $(addprefix arch/blackfin/cpu/, init.lds init.elf)
  930. @rm -f include/bmp_logo.h
  931. @rm -f include/bmp_logo_data.h
  932. @rm -f lib/asm-offsets.s
  933. @rm -f include/generated/asm-offsets.h
  934. @rm -f $(CPUDIR)/$(SOC)/asm-offsets.s
  935. @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
  936. @$(MAKE) -f $(srctree)/doc/DocBook/Makefile cleandocs
  937. @find $(OBJTREE) -type f \
  938. \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
  939. -o -name '*.o' -o -name '*.a' -o -name '*.exe' -o -name '*.cmd' \
  940. -o -name '*.cfgtmp' \) -print \
  941. | xargs rm -f
  942. # Removes everything not needed for testing u-boot
  943. tidy: clean
  944. @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
  945. clobber: tidy
  946. @find $(OBJTREE) -type f \( -name '*.srec' \
  947. -o -name '*.bin' -o -name u-boot.img \) \
  948. -print0 | xargs -0 rm -f
  949. @rm -f $(OBJS) *.bak ctags etags TAGS \
  950. cscope.* *.*~
  951. @rm -f u-boot u-boot.map u-boot.hex $(ALL-y)
  952. @rm -f u-boot.kwb
  953. @rm -f u-boot.pbl
  954. @rm -f u-boot.imx
  955. @rm -f u-boot-with-spl.imx
  956. @rm -f u-boot-with-nand-spl.imx
  957. @rm -f u-boot.ubl
  958. @rm -f u-boot.ais
  959. @rm -f u-boot.dtb
  960. @rm -f u-boot.sb
  961. @rm -f u-boot.spr
  962. @rm -f $(addprefix nand_spl/, u-boot.lds u-boot.lst System.map)
  963. @rm -f $(addprefix nand_spl/, u-boot-nand_spl.lds u-boot-spl u-boot-spl.map)
  964. @rm -f $(addprefix spl/, u-boot-spl u-boot-spl.bin u-boot-spl.map)
  965. @rm -f spl/u-boot-spl.lds
  966. @rm -f $(addprefix tpl/, u-boot-tpl u-boot-tpl.bin u-boot-tpl.map)
  967. @rm -f tpl/u-boot-spl.lds
  968. @rm -f MLO MLO.byteswap
  969. @rm -f SPL
  970. @rm -f tools/xway-swap-bytes
  971. @rm -fr include/asm/proc include/asm/arch include/asm
  972. @rm -fr include/generated
  973. @[ ! -d nand_spl ] || find nand_spl -name "*" -type l -print | xargs rm -f
  974. @rm -f dts/*.tmp
  975. @rm -f $(addprefix spl/, u-boot-spl.ais, u-boot-spl-pad.ais)
  976. mrproper \
  977. distclean: clobber unconfig
  978. ifneq ($(OBJTREE),$(SRCTREE))
  979. rm -rf *
  980. endif
  981. backup:
  982. F=`basename $(TOPDIR)` ; cd .. ; \
  983. gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
  984. #########################################################################
  985. endif # skip-makefile
  986. PHONY += FORCE
  987. FORCE:
  988. # Declare the contents of the .PHONY variable as phony. We keep that
  989. # information in a variable so we can use it in if_changed and friends.
  990. .PHONY: $(PHONY)