Makefile 27 KB

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