Makefile 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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 = -rc1
  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 = $(obj)include/generated/timestamp_autogenerated.h
  17. VERSION_FILE = $(obj)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. #########################################################################
  40. #
  41. # U-boot build supports generating object files in a separate external
  42. # directory. Two use cases are supported:
  43. #
  44. # 1) Add O= to the make command line
  45. # 'make O=/tmp/build all'
  46. #
  47. # 2) Set environment variable BUILD_DIR to point to the desired location
  48. # 'export BUILD_DIR=/tmp/build'
  49. # 'make'
  50. #
  51. # The second approach can also be used with a MAKEALL script
  52. # 'export BUILD_DIR=/tmp/build'
  53. # './MAKEALL'
  54. #
  55. # Command line 'O=' setting overrides BUILD_DIR environment variable.
  56. #
  57. # When none of the above methods is used the local build is performed and
  58. # the object files are placed in the source directory.
  59. #
  60. ifeq ("$(origin O)", "command line")
  61. BUILD_DIR := $(O)
  62. endif
  63. # Call a source code checker (by default, "sparse") as part of the
  64. # C compilation.
  65. #
  66. # Use 'make C=1' to enable checking of re-compiled files.
  67. #
  68. # See the linux kernel file "Documentation/sparse.txt" for more details,
  69. # including where to get the "sparse" utility.
  70. ifdef C
  71. ifeq ("$(origin C)", "command line")
  72. CHECKSRC := $(C)
  73. endif
  74. endif
  75. ifndef CHECKSRC
  76. CHECKSRC = 0
  77. endif
  78. export CHECKSRC
  79. ifneq ($(BUILD_DIR),)
  80. saved-output := $(BUILD_DIR)
  81. # Attempt to create a output directory.
  82. $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
  83. # Verify if it was successful.
  84. BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
  85. $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
  86. endif # ifneq ($(BUILD_DIR),)
  87. OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
  88. SPLTREE := $(OBJTREE)/spl
  89. TPLTREE := $(OBJTREE)/tpl
  90. SRCTREE := $(CURDIR)
  91. TOPDIR := $(SRCTREE)
  92. LNDIR := $(OBJTREE)
  93. export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
  94. MKCONFIG := $(SRCTREE)/mkconfig
  95. export MKCONFIG
  96. # $(obj) and (src) are defined in config.mk but here in main Makefile
  97. # we also need them before config.mk is included which is the case for
  98. # some targets like unconfig, clean, clobber, distclean, etc.
  99. ifneq ($(OBJTREE),$(SRCTREE))
  100. obj := $(OBJTREE)/
  101. src := $(SRCTREE)/
  102. else
  103. obj :=
  104. src :=
  105. endif
  106. export obj src
  107. # Make sure CDPATH settings don't interfere
  108. unexport CDPATH
  109. #########################################################################
  110. # The "tools" are needed early, so put this first
  111. # Don't include stuff already done in $(LIBS)
  112. # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
  113. # is "yes"), so compile examples after U-Boot is compiled.
  114. SUBDIR_TOOLS = tools
  115. SUBDIRS = $(SUBDIR_TOOLS)
  116. .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
  117. ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))
  118. # Include autoconf.mk before config.mk so that the config options are available
  119. # to all top level build files. We need the dummy all: target to prevent the
  120. # dependency target in autoconf.mk.dep from being the default.
  121. all:
  122. sinclude $(obj)include/autoconf.mk.dep
  123. sinclude $(obj)include/autoconf.mk
  124. SUBDIR_EXAMPLES-y := examples/standalone
  125. SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
  126. ifndef CONFIG_SANDBOX
  127. SUBDIRS += $(SUBDIR_EXAMPLES-y)
  128. endif
  129. # load ARCH, BOARD, and CPU configuration
  130. include $(obj)include/config.mk
  131. export ARCH CPU BOARD VENDOR SOC
  132. # set default to nothing for native builds
  133. ifeq ($(HOSTARCH),$(ARCH))
  134. CROSS_COMPILE ?=
  135. endif
  136. # load other configuration
  137. include $(TOPDIR)/config.mk
  138. # Targets which don't build the source code
  139. NON_BUILD_TARGETS = backup clean clobber distclean mkproper tidy unconfig
  140. # Only do the generic board check when actually building, not configuring
  141. ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)
  142. ifeq ($(findstring _config,$(MAKECMDGOALS)),)
  143. $(CHECK_GENERIC_BOARD)
  144. endif
  145. endif
  146. # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
  147. # that (or fail if absent). Otherwise, search for a linker script in a
  148. # standard location.
  149. LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))
  150. ifndef LDSCRIPT
  151. #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
  152. ifdef CONFIG_SYS_LDSCRIPT
  153. # need to strip off double quotes
  154. LDSCRIPT := $(CONFIG_SYS_LDSCRIPT:"%"=%)
  155. endif
  156. endif
  157. # If there is no specified link script, we look in a number of places for it
  158. ifndef LDSCRIPT
  159. ifeq ($(CONFIG_NAND_U_BOOT),y)
  160. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
  161. ifeq ($(wildcard $(LDSCRIPT)),)
  162. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
  163. endif
  164. endif
  165. ifeq ($(wildcard $(LDSCRIPT)),)
  166. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
  167. endif
  168. ifeq ($(wildcard $(LDSCRIPT)),)
  169. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds
  170. endif
  171. ifeq ($(wildcard $(LDSCRIPT)),)
  172. LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds
  173. # We don't expect a Makefile here
  174. LDSCRIPT_MAKEFILE_DIR =
  175. endif
  176. ifeq ($(wildcard $(LDSCRIPT)),)
  177. $(error could not find linker script)
  178. endif
  179. endif
  180. #########################################################################
  181. # U-Boot objects....order is important (i.e. start must be first)
  182. head-y := $(CPUDIR)/start.o
  183. head-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.o
  184. head-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.o
  185. OBJS := $(addprefix $(obj),$(head-y))
  186. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)
  187. LIBS-y += lib/
  188. LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  189. LIBS-y += $(CPUDIR)/
  190. ifdef SOC
  191. LIBS-y += $(CPUDIR)/$(SOC)/
  192. endif
  193. LIBS-$(CONFIG_IXP4XX_NPE) += drivers/net/npe/
  194. LIBS-$(CONFIG_OF_EMBED) += dts/
  195. LIBS-y += arch/$(ARCH)/lib/
  196. LIBS-y += fs/
  197. LIBS-y += net/
  198. LIBS-y += disk/
  199. LIBS-y += drivers/
  200. LIBS-y += drivers/dma/
  201. LIBS-y += drivers/gpio/
  202. LIBS-y += drivers/i2c/
  203. LIBS-y += drivers/input/
  204. LIBS-y += drivers/mmc/
  205. LIBS-y += drivers/mtd/
  206. LIBS-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
  207. LIBS-y += drivers/mtd/onenand/
  208. LIBS-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
  209. LIBS-y += drivers/mtd/spi/
  210. LIBS-y += drivers/net/
  211. LIBS-y += drivers/net/phy/
  212. LIBS-y += drivers/pci/
  213. LIBS-y += drivers/power/ \
  214. drivers/power/fuel_gauge/ \
  215. drivers/power/mfd/ \
  216. drivers/power/pmic/ \
  217. drivers/power/battery/
  218. LIBS-y += drivers/spi/
  219. LIBS-$(CONFIG_FMAN_ENET) += drivers/net/fm/
  220. LIBS-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
  221. LIBS-y += drivers/serial/
  222. LIBS-y += drivers/usb/eth/
  223. LIBS-y += drivers/usb/gadget/
  224. LIBS-y += drivers/usb/host/
  225. LIBS-y += drivers/usb/musb/
  226. LIBS-y += drivers/usb/musb-new/
  227. LIBS-y += drivers/usb/phy/
  228. LIBS-y += drivers/usb/ulpi/
  229. LIBS-y += common/
  230. LIBS-y += lib/libfdt/
  231. LIBS-$(CONFIG_API) += api/
  232. LIBS-$(CONFIG_HAS_POST) += post/
  233. LIBS-y += test/
  234. ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))
  235. LIBS-y += arch/$(ARCH)/imx-common/
  236. endif
  237. LIBS-$(CONFIG_ARM) += arch/arm/cpu/
  238. LIBS-$(CONFIG_PPC) += arch/powerpc/cpu/
  239. LIBS-y += board/$(BOARDDIR)/
  240. LIBS-y := $(patsubst %/, %/built-in.o, $(LIBS-y))
  241. LIBS := $(addprefix $(obj),$(sort $(LIBS-y)))
  242. .PHONY : $(LIBS)
  243. # Add GCC lib
  244. ifdef USE_PRIVATE_LIBGCC
  245. ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
  246. PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
  247. else
  248. PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
  249. endif
  250. else
  251. PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
  252. endif
  253. PLATFORM_LIBS += $(PLATFORM_LIBGCC)
  254. export PLATFORM_LIBS
  255. # Special flags for CPP when processing the linker script.
  256. # Pass the version down so we can handle backwards compatibility
  257. # on the fly.
  258. LDPPFLAGS += \
  259. -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  260. -DCPUDIR=$(CPUDIR) \
  261. $(shell $(LD) --version | \
  262. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  263. __OBJS := $(subst $(obj),,$(OBJS))
  264. __LIBS := $(subst $(obj),,$(LIBS))
  265. #########################################################################
  266. #########################################################################
  267. ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)
  268. BOARD_SIZE_CHECK = \
  269. @actual=`wc -c $@ | awk '{print $$1}'`; \
  270. limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \
  271. if test $$actual -gt $$limit; then \
  272. echo "$@ exceeds file size limit:" >&2 ; \
  273. echo " limit: $$limit bytes" >&2 ; \
  274. echo " actual: $$actual bytes" >&2 ; \
  275. echo " excess: $$((actual - limit)) bytes" >&2; \
  276. exit 1; \
  277. fi
  278. else
  279. BOARD_SIZE_CHECK =
  280. endif
  281. # Always append ALL so that arch config.mk's can add custom ones
  282. ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
  283. ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
  284. ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
  285. ALL-$(CONFIG_RAMBOOT_PBL) += $(obj)u-boot.pbl
  286. ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
  287. ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img
  288. ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
  289. ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
  290. ifneq ($(CONFIG_SPL_TARGET),)
  291. ALL-$(CONFIG_SPL) += $(obj)$(CONFIG_SPL_TARGET:"%"=%)
  292. endif
  293. # enable combined SPL/u-boot/dtb rules for tegra
  294. ifneq ($(CONFIG_TEGRA),)
  295. ifeq ($(CONFIG_OF_SEPARATE),y)
  296. ALL-y += $(obj)u-boot-dtb-tegra.bin
  297. else
  298. ALL-y += $(obj)u-boot-nodtb-tegra.bin
  299. endif
  300. endif
  301. build := -f $(TOPDIR)/scripts/Makefile.build -C
  302. all: $(ALL-y) $(SUBDIR_EXAMPLES-y)
  303. $(obj)u-boot.dtb: checkdtc $(obj)u-boot
  304. $(MAKE) $(build) dts binary
  305. mv $(obj)dts/dt.dtb $@
  306. $(obj)u-boot-dtb.bin: $(obj)u-boot.bin $(obj)u-boot.dtb
  307. cat $^ >$@
  308. $(obj)u-boot.hex: $(obj)u-boot
  309. $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
  310. $(obj)u-boot.srec: $(obj)u-boot
  311. $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
  312. $(obj)u-boot.bin: $(obj)u-boot
  313. $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
  314. $(BOARD_SIZE_CHECK)
  315. $(obj)u-boot.ldr: $(obj)u-boot
  316. $(CREATE_LDR_ENV)
  317. $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
  318. $(BOARD_SIZE_CHECK)
  319. $(obj)u-boot.ldr.hex: $(obj)u-boot.ldr
  320. $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
  321. $(obj)u-boot.ldr.srec: $(obj)u-boot.ldr
  322. $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
  323. #
  324. # U-Boot entry point, needed for booting of full-blown U-Boot
  325. # from the SPL U-Boot version.
  326. #
  327. ifndef CONFIG_SYS_UBOOT_START
  328. CONFIG_SYS_UBOOT_START := 0
  329. endif
  330. $(obj)u-boot.img: $(obj)u-boot.bin
  331. $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
  332. -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \
  333. -e $(CONFIG_SYS_UBOOT_START) \
  334. -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
  335. sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
  336. -d $< $@
  337. $(obj)u-boot.imx: $(obj)u-boot.bin depend
  338. $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common $(OBJTREE)/u-boot.imx
  339. $(obj)u-boot.kwb: $(obj)u-boot.bin
  340. $(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \
  341. -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
  342. $(obj)u-boot.pbl: $(obj)u-boot.bin
  343. $(obj)tools/mkimage -n $(CONFIG_PBLRCW_CONFIG) \
  344. -R $(CONFIG_PBLPBI_CONFIG) -T pblimage \
  345. -d $< $@
  346. $(obj)u-boot.sha1: $(obj)u-boot.bin
  347. $(obj)tools/ubsha1 $(obj)u-boot.bin
  348. $(obj)u-boot.dis: $(obj)u-boot
  349. $(OBJDUMP) -d $< > $@
  350. # $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,
  351. # $(4) is pad-to
  352. SPL_PAD_APPEND = \
  353. $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \
  354. $(1) $(obj)$(3); \
  355. cat $(obj)$(3) $(2) > $@; \
  356. rm $(obj)$(3)
  357. ifdef CONFIG_TPL
  358. SPL_PAYLOAD := $(obj)tpl/u-boot-with-tpl.bin
  359. else
  360. SPL_PAYLOAD := $(obj)u-boot.bin
  361. endif
  362. $(obj)u-boot-with-spl.bin: $(obj)spl/u-boot-spl.bin $(SPL_PAYLOAD)
  363. $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))
  364. $(obj)tpl/u-boot-with-tpl.bin: $(obj)tpl/u-boot-tpl.bin $(obj)u-boot.bin
  365. $(call SPL_PAD_APPEND,$<,$(obj)u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))
  366. $(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
  367. $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \
  368. $(OBJTREE)/u-boot-with-spl.imx
  369. $(obj)u-boot-with-nand-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
  370. $(MAKE) $(build) $(SRCTREE)/arch/arm/imx-common \
  371. $(OBJTREE)/u-boot-with-nand-spl.imx
  372. $(obj)u-boot.ubl: $(obj)u-boot-with-spl.bin
  373. $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
  374. -e $(CONFIG_SYS_TEXT_BASE) -d $< $(obj)u-boot.ubl
  375. $(obj)u-boot.ais: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
  376. $(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \
  377. -T aisimage \
  378. -e $(CONFIG_SPL_TEXT_BASE) \
  379. -d $(obj)spl/u-boot-spl.bin \
  380. $(obj)spl/u-boot-spl.ais
  381. $(OBJCOPY) ${OBJCFLAGS} -I binary \
  382. --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
  383. $(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
  384. cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \
  385. $(obj)u-boot.ais
  386. $(obj)u-boot.sb: $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
  387. $(MAKE) $(build) $(SRCTREE)/$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb
  388. # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
  389. # Both images are created using mkimage (crc etc), so that the ROM
  390. # bootloader can check its integrity. Padding needs to be done to the
  391. # SPL image (with mkimage header) and not the binary. Otherwise the resulting image
  392. # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
  393. # The resulting image containing both U-Boot images is called u-boot.spr
  394. $(obj)u-boot.spr: $(obj)u-boot.img $(obj)spl/u-boot-spl.bin
  395. $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
  396. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \
  397. -d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img
  398. tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \
  399. of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null
  400. dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \
  401. conv=notrunc 2>/dev/null
  402. cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@
  403. ifneq ($(CONFIG_TEGRA),)
  404. $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
  405. $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
  406. cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@
  407. rm $(obj)spl/u-boot-spl-pad.bin
  408. ifeq ($(CONFIG_OF_SEPARATE),y)
  409. $(obj)u-boot-dtb-tegra.bin: $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb
  410. cat $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb > $@
  411. endif
  412. endif
  413. $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
  414. cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@
  415. # PPC4xx needs the SPL at the end of the image, since the reset vector
  416. # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
  417. # and need to introduce a new build target with the full blown U-Boot
  418. # at the start padded up to the start of the SPL image. And then concat
  419. # the SPL image to the end.
  420. $(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img
  421. tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \
  422. of=$(obj)u-boot-pad.img 2>/dev/null
  423. dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \
  424. conv=notrunc 2>/dev/null
  425. cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@
  426. ifeq ($(CONFIG_SANDBOX),y)
  427. GEN_UBOOT = \
  428. cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \
  429. -Wl,--start-group $(__LIBS) -Wl,--end-group \
  430. $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot
  431. else
  432. GEN_UBOOT = \
  433. cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
  434. $(__OBJS) \
  435. --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
  436. -Map u-boot.map -o u-boot
  437. endif
  438. $(obj)u-boot: depend \
  439. $(SUBDIR_TOOLS) $(OBJS) $(LIBS) $(obj)u-boot.lds
  440. $(GEN_UBOOT)
  441. ifeq ($(CONFIG_KALLSYMS),y)
  442. smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \
  443. awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
  444. $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
  445. -c common/system_map.c -o $(obj)common/system_map.o
  446. $(GEN_UBOOT) $(obj)common/system_map.o
  447. endif
  448. $(OBJS):
  449. @:
  450. $(LIBS): depend $(SUBDIR_TOOLS)
  451. $(MAKE) $(build) $(dir $(subst $(obj),,$@))
  452. $(SUBDIRS): depend
  453. $(MAKE) -C $@ all
  454. $(SUBDIR_EXAMPLES-y): $(obj)u-boot
  455. $(obj)u-boot.lds: $(LDSCRIPT) depend
  456. $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@
  457. nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend
  458. $(MAKE) -C nand_spl/board/$(BOARDDIR) all
  459. $(obj)u-boot-nand.bin: nand_spl $(obj)u-boot.bin
  460. cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
  461. $(obj)spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend
  462. $(MAKE) -C spl all
  463. $(obj)tpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend
  464. $(MAKE) -C spl all CONFIG_TPL_BUILD=y
  465. # Explicitly make _depend in subdirs containing multiple targets to prevent
  466. # parallel sub-makes creating .depend files simultaneously.
  467. depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \
  468. $(obj)include/spl-autoconf.mk \
  469. $(obj)include/tpl-autoconf.mk \
  470. $(obj)include/autoconf.mk \
  471. $(obj)include/generated/generic-asm-offsets.h \
  472. $(obj)include/generated/asm-offsets.h
  473. TAG_SUBDIRS = $(SUBDIRS)
  474. TAG_SUBDIRS += $(dir $(__LIBS))
  475. TAG_SUBDIRS += include
  476. FIND := find
  477. FINDFLAGS := -L
  478. checkstack:
  479. $(CROSS_COMPILE)objdump -d $(obj)u-boot \
  480. `$(FIND) $(obj) -name u-boot-spl -print` | \
  481. perl $(src)scripts/checkstack.pl $(ARCH)
  482. tags ctags:
  483. ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  484. -name '*.[chS]' -print`
  485. etags:
  486. etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
  487. -name '*.[chS]' -print`
  488. cscope:
  489. $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
  490. cscope.files
  491. cscope -b -q -k
  492. SYSTEM_MAP = \
  493. $(NM) $1 | \
  494. grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
  495. LC_ALL=C sort
  496. $(obj)System.map: $(obj)u-boot
  497. @$(call SYSTEM_MAP,$<) > $@
  498. checkthumb:
  499. @if test $(call cc-version) -lt 0404; then \
  500. echo -n '*** Your GCC does not produce working '; \
  501. echo 'binaries in THUMB mode.'; \
  502. echo '*** Your board is configured for THUMB mode.'; \
  503. false; \
  504. fi
  505. # GCC 3.x is reported to have problems generating the type of relocation
  506. # that U-Boot wants.
  507. # See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html
  508. checkgcc4:
  509. @if test $(call cc-version) -lt 0400; then \
  510. echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \
  511. false; \
  512. fi
  513. checkdtc:
  514. @if test $(call dtc-version) -lt 0104; then \
  515. echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
  516. false; \
  517. fi
  518. #
  519. # Auto-generate the autoconf.mk file (which is included by all makefiles)
  520. #
  521. # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.
  522. # the dep file is only include in this top level makefile to determine when
  523. # to regenerate the autoconf.mk file.
  524. $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h
  525. @$(XECHO) Generating $@ ; \
  526. : Generate the dependancies ; \
  527. $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \
  528. -MQ $(obj)include/autoconf.mk include/common.h > $@ || \
  529. rm $@
  530. $(obj)include/autoconf.mk: $(obj)include/config.h
  531. @$(XECHO) Generating $@ ; \
  532. : Extract the config macros ; \
  533. $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
  534. sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
  535. rm $@.tmp
  536. # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
  537. $(obj)include/tpl-autoconf.mk: $(obj)include/config.h
  538. @$(XECHO) Generating $@ ; \
  539. : Extract the config macros ; \
  540. $(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD -DCONFIG_SPL_BUILD\
  541. -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
  542. sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
  543. rm $@.tmp
  544. $(obj)include/spl-autoconf.mk: $(obj)include/config.h
  545. @$(XECHO) Generating $@ ; \
  546. : Extract the config macros ; \
  547. $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h > $@.tmp && \
  548. sed -n -f tools/scripts/define2mk.sed $@.tmp > $@; \
  549. rm $@.tmp
  550. $(obj)include/generated/generic-asm-offsets.h: $(obj)lib/asm-offsets.s
  551. @$(XECHO) Generating $@
  552. tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@
  553. $(obj)lib/asm-offsets.s: $(obj)include/config.h $(src)lib/asm-offsets.c
  554. @mkdir -p $(obj)lib
  555. $(CC) -DDO_DEPS_ONLY \
  556. $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
  557. -o $@ $(src)lib/asm-offsets.c -c -S
  558. $(obj)include/generated/asm-offsets.h: $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
  559. @$(XECHO) Generating $@
  560. tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@
  561. $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s: $(obj)include/config.h
  562. @mkdir -p $(obj)$(CPUDIR)/$(SOC)
  563. if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \
  564. $(CC) -DDO_DEPS_ONLY \
  565. $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \
  566. -o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \
  567. else \
  568. touch $@; \
  569. fi
  570. #########################################################################
  571. else # !config.mk
  572. all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \
  573. $(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \
  574. $(filter-out tools,$(SUBDIRS)) \
  575. depend dep tags ctags etags cscope $(obj)System.map:
  576. @echo "System not configured - see README" >&2
  577. @ exit 1
  578. tools: $(VERSION_FILE) $(TIMESTAMP_FILE)
  579. $(MAKE) -C $@ all
  580. endif # config.mk
  581. # ARM relocations should all be R_ARM_RELATIVE.
  582. checkarmreloc: $(obj)u-boot
  583. @if test "R_ARM_RELATIVE" != \
  584. "`$(CROSS_COMPILE)readelf -r $< | cut -d ' ' -f 4 | grep R_ARM | sort -u`"; \
  585. then echo "$< contains relocations other than \
  586. R_ARM_RELATIVE"; false; fi
  587. $(VERSION_FILE):
  588. @mkdir -p $(dir $(VERSION_FILE))
  589. @( localvers='$(shell $(TOPDIR)/scripts/setlocalversion $(TOPDIR))' ; \
  590. printf '#define PLAIN_VERSION "%s%s"\n' \
  591. "$(U_BOOT_VERSION)" "$${localvers}" ; \
  592. printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \
  593. "$(U_BOOT_VERSION)" "$${localvers}" ; \
  594. ) > $@.tmp
  595. @( printf '#define CC_VERSION_STRING "%s"\n' \
  596. '$(shell $(CC) --version | head -n 1)' )>> $@.tmp
  597. @( printf '#define LD_VERSION_STRING "%s"\n' \
  598. '$(shell $(LD) -v | head -n 1)' )>> $@.tmp
  599. @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
  600. $(TIMESTAMP_FILE):
  601. @mkdir -p $(dir $(TIMESTAMP_FILE))
  602. @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp
  603. @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp
  604. @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@
  605. easylogo env gdb:
  606. $(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}
  607. gdbtools: gdb
  608. xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc
  609. $(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@
  610. tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)
  611. $(MAKE) -C tools HOST_TOOLS_ALL=y
  612. .PHONY : CHANGELOG
  613. CHANGELOG:
  614. git log --no-merges U-Boot-1_1_5.. | \
  615. unexpand -a | sed -e 's/\s\s*$$//' > $@
  616. include/license.h: tools/bin2header COPYING
  617. cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h
  618. #########################################################################
  619. unconfig:
  620. @rm -f $(obj)include/config.h $(obj)include/config.mk \
  621. $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
  622. $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \
  623. $(obj)include/spl-autoconf.mk \
  624. $(obj)include/tpl-autoconf.mk
  625. %_config:: unconfig
  626. @$(MKCONFIG) -A $(@:_config=)
  627. sinclude $(obj).boards.depend
  628. $(obj).boards.depend: boards.cfg
  629. @awk '(NF && $$1 !~ /^#/) { print $$7 ": " $$7 "_config; $$(MAKE)" }' $< > $@
  630. #########################################################################
  631. #########################################################################
  632. clean:
  633. @rm -f $(obj)examples/standalone/atmel_df_pow2 \
  634. $(obj)examples/standalone/hello_world \
  635. $(obj)examples/standalone/interrupt \
  636. $(obj)examples/standalone/mem_to_mem_idma2intr \
  637. $(obj)examples/standalone/sched \
  638. $(obj)examples/standalone/smc911{11,x}_eeprom \
  639. $(obj)examples/standalone/test_burst \
  640. $(obj)examples/standalone/timer
  641. @rm -f $(obj)examples/api/demo{,.bin}
  642. @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \
  643. $(obj)tools/env/fw_printenv \
  644. $(obj)tools/envcrc \
  645. $(obj)tools/gdb/{gdbcont,gdbsend} \
  646. $(obj)tools/gen_eth_addr $(obj)tools/img2srec \
  647. $(obj)tools/dump{env,}image \
  648. $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \
  649. $(obj)tools/mk{$(BOARD),}spl \
  650. $(obj)tools/mxsboot \
  651. $(obj)tools/ncb $(obj)tools/ubsha1 \
  652. $(obj)tools/kernel-doc/docproc \
  653. $(obj)tools/proftool
  654. @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image} \
  655. $(obj)board/matrix_vision/*/bootscript.img \
  656. $(obj)u-boot.lds \
  657. $(obj)arch/blackfin/cpu/init.{lds,elf}
  658. @rm -f $(obj)include/bmp_logo.h
  659. @rm -f $(obj)include/bmp_logo_data.h
  660. @rm -f $(obj)lib/asm-offsets.s
  661. @rm -f $(obj)include/generated/asm-offsets.h
  662. @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
  663. @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
  664. @$(MAKE) -s -C doc/DocBook/ cleandocs
  665. @find $(OBJTREE) -type f \
  666. \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
  667. -o -name '*.o' -o -name '*.a' -o -name '*.exe' \
  668. -o -name '*.cfgtmp' \) -print \
  669. | xargs rm -f
  670. # Removes everything not needed for testing u-boot
  671. tidy: clean
  672. @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f
  673. clobber: tidy
  674. @find $(OBJTREE) -type f \( -name '*.srec' \
  675. -o -name '*.bin' -o -name u-boot.img \) \
  676. -print0 | xargs -0 rm -f
  677. @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
  678. $(obj)cscope.* $(obj)*.*~
  679. @rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
  680. @rm -f $(obj)u-boot.kwb
  681. @rm -f $(obj)u-boot.pbl
  682. @rm -f $(obj)u-boot.imx
  683. @rm -f $(obj)u-boot-with-spl.imx
  684. @rm -f $(obj)u-boot-with-nand-spl.imx
  685. @rm -f $(obj)u-boot.ubl
  686. @rm -f $(obj)u-boot.ais
  687. @rm -f $(obj)u-boot.dtb
  688. @rm -f $(obj)u-boot.sb
  689. @rm -f $(obj)u-boot.spr
  690. @rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map}
  691. @rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
  692. @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}
  693. @rm -f $(obj)spl/u-boot-spl.lds
  694. @rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map}
  695. @rm -f $(obj)tpl/u-boot-spl.lds
  696. @rm -f $(obj)MLO MLO.byteswap
  697. @rm -f $(obj)SPL
  698. @rm -f $(obj)tools/xway-swap-bytes
  699. @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
  700. @rm -fr $(obj)include/generated
  701. @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
  702. @rm -f $(obj)dts/*.tmp
  703. @rm -f $(obj)spl/u-boot-spl{,-pad}.ais
  704. mrproper \
  705. distclean: clobber unconfig
  706. ifneq ($(OBJTREE),$(SRCTREE))
  707. rm -rf $(obj)*
  708. endif
  709. backup:
  710. F=`basename $(TOPDIR)` ; cd .. ; \
  711. gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
  712. #########################################################################