Makefile 27 KB

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