uboot2013-10移植(一)--Makefile注释

来源:互联网 发布:如何让win7网络更流畅 编辑:程序博客网 时间:2024/06/15 04:25

转载地址:http://blog.csdn.net/fjlhlonng/article/details/21880233

板子:TQ210

参考了网上的一些文章,在这里就不一一列举了,十分感谢那些作者的分享~


[cpp] view plain copy
  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.   
  8. VERSION = 2013  
  9. PATCHLEVEL = 10  
  10. SUBLEVEL =  
  11. EXTRAVERSION =  
  12. ifneq "$(SUBLEVEL)" ""  
  13. U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)  
  14. else  
  15. U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION) #值为2013.10  
  16. endif  
  17. TIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h #obj为空  
  18. VERSION_FILE = $(obj)include/generated/version_autogenerated.h  
  19.   
  20. # HOSTARCH = x86  
  21. HOSTARCH := $(shell uname -m | \  
  22.     sed -e s/i.86/x86/ \  
  23.         -e s/sun4u/sparc64/ \  
  24.         -e s/arm.*/arm/ \  
  25.         -e s/sa110/arm/ \  
  26.         -e s/ppc64/powerpc/ \  
  27.         -e s/ppc/powerpc/ \  
  28.         -e s/macppc/powerpc/\  
  29.         -e s/sh.*/sh/)  
  30.   
  31. # HOSTOS = linux ; uname -s 得到:"Linux",经过tr命令处理以后变成小写的字符串  
  32. HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \  
  33.         sed -e 's/cygwin.*/cygwin/')  
  34.   
  35. export  HOSTARCH HOSTOS  
  36.   
  37. # Deal with colliding definitions from tcsh etc.  
  38. VENDOR=  
  39.   
  40. #########################################################################  
  41. # Allow for silent builds  
  42. # 如果在变量MAKEFLAGS中没有s这个参数,那么XECHO = echo  
  43. ifeq (,$(findstring s,$(MAKEFLAGS)))  
  44. XECHO = echo #该变量会被赋值  
  45. else  
  46. XECHO = :  
  47. endif  
  48.   
  49. #########################################################################  
  50. #  
  51. # U-boot build supports generating object files in a separate external  
  52. # directory. Two use cases are supported:  
  53. #  
  54. # 1) Add O= to the make command line  
  55. # 'make O=/tmp/build all'  
  56. #  
  57. # 2) Set environment variable BUILD_DIR to point to the desired location  
  58. # 'export BUILD_DIR=/tmp/build'  
  59. # 'make'  
  60. #  
  61. # The second approach can also be used with a MAKEALL script  
  62. # 'export BUILD_DIR=/tmp/build'  
  63. # './MAKEALL'  
  64. #  
  65. # Command line 'O=' setting overrides BUILD_DIR environment variable.  
  66. #  
  67. # When none of the above methods is used the local build is performed and  
  68. # the object files are placed in the source directory.  
  69. #  
  70.   
  71. ifdef O # 这一段表示假如已经定义了一个O变量,而且它来自命令行,那么复制给BUILD_DIR  
  72. ifeq ("$(origin O)""command line")  
  73. BUILD_DIR := $(O)  
  74. endif  
  75. endif  
  76.   
  77. # Call a source code checker (by default, "sparse") as part of the  
  78. # C compilation.  
  79. #  
  80. # Use 'make C=1' to enable checking of re-compiled files.  
  81. #  
  82. # See the linux kernel file "Documentation/sparse.txt" for more details,  
  83. # including where to get the "sparse" utility.  
  84.   
  85. ifdef C # 参考上一段  
  86. ifeq ("$(origin C)""command line")  
  87. CHECKSRC := $(C)  
  88. endif  
  89. endif  
  90. ifndef CHECKSRC  
  91.   CHECKSRC = 0 # 会执行赋值操作  
  92. endif  
  93. export CHECKSRC  
  94.   
  95. ifneq ($(BUILD_DIR),) # BUILD_DIR为空,所以条件不成立  
  96. saved-output := $(BUILD_DIR) # 不执行  
  97.   
  98. # Attempt to create a output directory.  
  99. $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}) # 不执行  
  100.   
  101. # Verify if it was successful.  
  102. BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) # 不执行  
  103. # 不执行  
  104. $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))  
  105. endif # ifneq ($(BUILD_DIR),)  
  106.   
  107. # OBJTREE 为源码所在目录,等于CURDIR这个变量  
  108. OBJTREE     := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))  
  109. SPLTREE     := $(OBJTREE)/spl  
  110. TPLTREE     := $(OBJTREE)/tpl  
  111. SRCTREE     := $(CURDIR)  
  112. TOPDIR      := $(SRCTREE)  
  113. LNDIR       := $(OBJTREE)  
  114. export  TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE  
  115.   
  116. MKCONFIG    := $(SRCTREE)/mkconfig  
  117. export MKCONFIG  
  118.   
  119. ifneq ($(OBJTREE),$(SRCTREE))  
  120. REMOTE_BUILD    := 1 # 这里自然不会执行  
  121. export REMOTE_BUILD  
  122. endif  
  123.   
  124. # $(obj) and (src) are defined in config.mk but here in main Makefile  
  125. # we also need them before config.mk is included which is the case for  
  126. # some targets like unconfig, clean, clobber, distclean, etc.  
  127. ifneq ($(OBJTREE),$(SRCTREE))  
  128. obj := $(OBJTREE)/  
  129. src := $(SRCTREE)/  
  130. else # 执行这里,obj 和 src 被赋空值  
  131. obj :=  
  132. src :=  
  133. endif  
  134. export obj src  
  135.   
  136. # Make sure CDPATH settings don't interfere  
  137. unexport CDPATH  
  138.   
  139. #########################################################################  
  140.   
  141. # The "tools" are needed early, so put this first  
  142. # Don't include stuff already done in $(LIBS)  
  143. # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC  
  144. # is "yes"), so compile examples after U-Boot is compiled.  
  145. SUBDIR_TOOLS = tools  
  146. SUBDIR_EXAMPLES = examples/standalone examples/api  
  147. SUBDIRS = $(SUBDIR_TOOLS)  
  148.   
  149. .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)  
  150.   
  151. # config.mk文件是执行:make xxx_config以后创建的  
  152. # 这里是用wildcard函数匹配出该文件,然后进行比较。  
  153. ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk))  
  154.   
  155. # Include autoconf.mk before config.mk so that the config options are available  
  156. # to all top level build files.  We need the dummy all: target to prevent the  
  157. # dependency target in autoconf.mk.dep from being the default.  
  158. all:  
  159. sinclude $(obj)include/autoconf.mk.dep # sinclude和-include一样,忽略不存在的文件,继续执行  
  160. sinclude $(obj)include/autoconf.mk  
  161.   
  162. # 我们的文件中未定义该宏 SUBDIRS  = tools examples/standalone examples/api  
  163. ifndef CONFIG_SANDBOX  
  164. SUBDIRS += $(SUBDIR_EXAMPLES)  
  165. endif  
  166.   
  167. # load ARCH, BOARD, and CPU configuration  
  168. include $(obj)include/config.mk  
  169. # 以下就是config.mk中的内容了  
  170. # ARCH   = arm  
  171. # CPU    = armv7  
  172. # BOARD  = smdkc100  
  173. # VENDOR = samsung  
  174. # SOC    = s5pc1xx  
  175. export  ARCH CPU BOARD VENDOR SOC  
  176.   
  177. # set default to nothing for native builds  
  178. # 判断主机架构是目标架构是否相同  
  179. # 我比较懒,直接在/etc/profile中定义了CROSS_COMPILE变量并用export导出了  
  180. ifeq ($(HOSTARCH),$(ARCH))  
  181. CROSS_COMPILE ?=  
  182. endif  
  183.   
  184. # load other configuration 加载源码根目录下的config.mk文件,待会分析  
  185. include $(TOPDIR)/config.mk  
  186.   
  187. # Targets which don't build the source code  
  188. # 一些不会进行编译源代码的目标集  
  189. NON_BUILD_TARGETS = backup clean clobber distclean mkproper tidy unconfig  
  190.   
  191. # Only do the generic board check when actually building, not configuring  
  192. # filter函数过滤出在MAKECMDGOALS中符合NON_BUILD_TARGETS的字串  
  193. # 然后把得到的结果通过ifeq命令进行判断是否为空  
  194. # 如果make命令之后的目标没有在NON_BUILD_TARGETS中,进入下一层判断  
  195. ifeq ($(filter $(NON_BUILD_TARGETS),$(MAKECMDGOALS)),)  
  196. # 如果MAKECMDGOALS不存在包含_config字串的目标,条件成立  
  197. ifeq ($(findstring _config,$(MAKECMDGOALS)),)  
  198. $(CHECK_GENERIC_BOARD)  
  199. endif  
  200. endif  
  201.   
  202. # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use  
  203. # that (or fail if absent).  Otherwise, search for a linker script in a  
  204. # standard location.  
  205. # 到目前为止,LDSCRIPT变量是没有定义的,LDSCRIPT下面会被赋值,所以LDSCRIPT_MAKEFILE_DIR是不需要的  
  206. LDSCRIPT_MAKEFILE_DIR = $(dir $(LDSCRIPT))  
  207.   
  208. ifndef LDSCRIPT # 条件成立  
  209.     #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug  
  210.     ifdef CONFIG_SYS_LDSCRIPT # 在smdkc100.h中未定义该宏  
  211.         # need to strip off double quotes  
  212.         LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))  
  213.     endif  
  214. endif  
  215.   
  216. # If there is no specified link script, we look in a number of places for it  
  217. ifndef LDSCRIPT # 这一段就是寻找链接脚本的过程  
  218.     ifeq ($(CONFIG_NAND_U_BOOT),y) # 未定义  
  219.         LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds  
  220.         ifeq ($(wildcard $(LDSCRIPT)),)  
  221.             LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds  
  222.         endif  
  223.     endif  
  224.     ifeq ($(wildcard $(LDSCRIPT)),) # LDSCRIPT此时为空,所以成立  
  225.         LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds  
  226.     endif  
  227.     ifeq ($(wildcard $(LDSCRIPT)),) # 虽然上面LDSCRIPT被赋值,但是lds文件不存在,所以这里仍然成立  
  228.         LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds  
  229.     endif  
  230.     ifeq ($(wildcard $(LDSCRIPT)),) # 为空,仍然成立  
  231.         # 最终LDSCRIPT等于/home/tomato/u-boot-2013.10/arch/arm/cpu/u-boot.lds  
  232.         LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot.lds  
  233.         # We don't expect a Makefile here  
  234.         LDSCRIPT_MAKEFILE_DIR =  
  235.     endif  
  236.     ifeq ($(wildcard $(LDSCRIPT)),) # 如果没找到就要报错退出了  
  237. $(error could not find linker script)  
  238.     endif  
  239. endif  
  240.   
  241. #########################################################################  
  242. # U-Boot objects....order is important (i.e. start must be first)  
  243. # CURDIR = arch/arm/cpu/armv7  
  244. OBJS  = $(CPUDIR)/start.o  
  245.   
  246. ifeq ($(CPU),ppc4xx) # 不成立  
  247. OBJS += $(CPUDIR)/resetvec.o  
  248. endif  
  249. ifeq ($(CPU),mpc85xx) # 不成立  
  250. OBJS += $(CPUDIR)/resetvec.o  
  251. endif  
  252.   
  253. OBJS := $(addprefix $(obj),$(OBJS)) # obj为空,所以变量没什么变化  
  254. # 下面这个变量值被赋为:y; 精简目录的时候,board/samsung/common这个目录需要保留  
  255. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard board/$(VENDOR)/common/Makefile),y,n)  
  256.   
  257. LIBS-y += lib/libgeneric.o  
  258. LIBS-y += lib/rsa/librsa.o  
  259. LIBS-y += lib/lzma/liblzma.o  
  260. LIBS-y += lib/lzo/liblzo.o  
  261. LIBS-y += lib/zlib/libz.o  
  262. LIBS-$(CONFIG_TIZEN) += lib/tizen/libtizen.o # 不添加  
  263. # 添加 board/samsung/common/libsamsung.o  
  264. LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o # 会添加  
  265. # 添加 arch/arm/cpu/armv7/libarmv7.o  
  266. LIBS-y += $(CPUDIR)/lib$(CPU).o  
  267. # 添加arch/arm/cpu/armv7/s5pc1xx/libs5pc1xx.o  
  268. ifdef SOC  
  269. LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o  
  270. endif  
  271. ifeq ($(CPU),ixp) # 不成立  
  272. LIBS-y += drivers/net/npe/libnpe.o  
  273. endif  
  274. # CONFIG_OF_EMBED 未定义  
  275. LIBS-$(CONFIG_OF_EMBED) += dts/libdts.o  
  276. # 添加arch/arm/lib/libarm.o  
  277. LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o  
  278. LIBS-y += fs/libfs.o \  
  279.     fs/cbfs/libcbfs.o \  
  280.     fs/cramfs/libcramfs.o \  
  281.     fs/ext4/libext4fs.o \  
  282.     fs/fat/libfat.o \  
  283.     fs/fdos/libfdos.o \  
  284.     fs/jffs2/libjffs2.o \  
  285.     fs/reiserfs/libreiserfs.o \  
  286.     fs/sandbox/libsandboxfs.o \  
  287.     fs/ubifs/libubifs.o \  
  288.     fs/yaffs2/libyaffs2.o \  
  289.     fs/zfs/libzfs.o  
  290. LIBS-y += net/libnet.o  
  291. LIBS-y += disk/libdisk.o  
  292. LIBS-y += drivers/bios_emulator/libatibiosemu.o  
  293. LIBS-y += drivers/block/libblock.o  
  294. # CONFIG_BOOTCOUNT_LIMIT未定义  
  295. LIBS-$(CONFIG_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o  
  296. LIBS-y += drivers/crypto/libcrypto.o  
  297. LIBS-y += drivers/dma/libdma.o  
  298. LIBS-y += drivers/fpga/libfpga.o  
  299. LIBS-y += drivers/gpio/libgpio.o  
  300. LIBS-y += drivers/hwmon/libhwmon.o  
  301. LIBS-y += drivers/i2c/libi2c.o  
  302. LIBS-y += drivers/input/libinput.o  
  303. LIBS-y += drivers/misc/libmisc.o  
  304. LIBS-y += drivers/mmc/libmmc.o  
  305. LIBS-y += drivers/mtd/libmtd.o  
  306. LIBS-y += drivers/mtd/nand/libnand.o  
  307. LIBS-y += drivers/mtd/onenand/libonenand.o  
  308. LIBS-y += drivers/mtd/ubi/libubi.o  
  309. LIBS-y += drivers/mtd/spi/libspi_flash.o  
  310. LIBS-y += drivers/net/libnet.o  
  311. LIBS-y += drivers/net/phy/libphy.o  
  312. LIBS-y += drivers/pci/libpci.o  
  313. LIBS-y += drivers/pcmcia/libpcmcia.o  
  314. LIBS-y += drivers/power/libpower.o \  
  315.     drivers/power/fuel_gauge/libfuel_gauge.o \  
  316.     drivers/power/mfd/libmfd.o \  
  317.     drivers/power/pmic/libpmic.o \  
  318.     drivers/power/battery/libbattery.o  
  319. LIBS-y += drivers/spi/libspi.o  
  320. LIBS-y += drivers/dfu/libdfu.o  
  321. ifeq ($(CPU),mpc83xx) # 不成立  
  322. LIBS-y += drivers/qe/libqe.o  
  323. LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o  
  324. LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o  
  325. endif  
  326. ifeq ($(CPU),mpc85xx) # 不成立  
  327. LIBS-y += drivers/qe/libqe.o  
  328. LIBS-y += drivers/net/fm/libfm.o  
  329. LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o  
  330. LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o  
  331. endif  
  332. ifeq ($(CPU),mpc86xx) # 不成立  
  333. LIBS-y += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o  
  334. LIBS-y += arch/powerpc/cpu/mpc8xxx/lib8xxx.o  
  335. endif  
  336. LIBS-y += drivers/rtc/librtc.o  
  337. LIBS-y += drivers/serial/libserial.o  
  338. LIBS-y += drivers/sound/libsound.o  
  339. LIBS-y += drivers/tpm/libtpm.o  
  340. LIBS-y += drivers/twserial/libtws.o  
  341. LIBS-y += drivers/usb/eth/libusb_eth.o  
  342. LIBS-y += drivers/usb/gadget/libusb_gadget.o  
  343. LIBS-y += drivers/usb/host/libusb_host.o  
  344. LIBS-y += drivers/usb/musb/libusb_musb.o  
  345. LIBS-y += drivers/usb/musb-new/libusb_musb-new.o  
  346. LIBS-y += drivers/usb/phy/libusb_phy.o  
  347. LIBS-y += drivers/usb/ulpi/libusb_ulpi.o  
  348. LIBS-y += drivers/video/libvideo.o  
  349. LIBS-y += drivers/watchdog/libwatchdog.o  
  350. LIBS-y += common/libcommon.o  
  351. LIBS-y += lib/libfdt/libfdt.o  
  352. LIBS-y += api/libapi.o  
  353. LIBS-y += post/libpost.o  
  354. LIBS-y += test/libtest.o  
  355.   
  356. ifneq ($(CONFIG_OMAP_COMMON),) # 不成立  
  357. LIBS-y += $(CPUDIR)/omap-common/libomap-common.o  
  358. endif  
  359.   
  360. # 不成立  
  361. ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))  
  362. LIBS-y += arch/$(ARCH)/imx-common/libimx-common.o  
  363. endif  
  364.   
  365. ifeq ($(SOC),s5pc1xx)  
  366. LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o # 被添加  
  367. endif  
  368.   
  369. # 不成立  
  370. ifeq ($(SOC),exynos)  
  371. LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o  
  372. endif  
  373.   
  374. # 不成立  
  375. ifneq ($(CONFIG_TEGRA),)  
  376. LIBS-y += arch/$(ARCH)/cpu/$(SOC)-common/lib$(SOC)-common.o  
  377. LIBS-y += arch/$(ARCH)/cpu/tegra-common/libcputegra-common.o  
  378. LIBS-y += $(CPUDIR)/tegra-common/libtegra-common.o  
  379. endif  
  380.   
  381. # 通过sort函数对字串进行排序  
  382. LIBS := $(addprefix $(obj),$(sort $(LIBS-y)))  
  383. .PHONY : $(LIBS)  
  384.   
  385. # 变量:LIBBOARD  = board/samsung/smdkc100/libsmdkc100.o  
  386. LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o  
  387. LIBBOARD := $(addprefix $(obj),$(LIBBOARD))  
  388.   
  389. # Add GCC lib  
  390. ifdef USE_PRIVATE_LIBGCC # 未定义  
  391. ifeq ("$(USE_PRIVATE_LIBGCC)""yes") # 不成立  
  392. PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o  
  393. else #   
  394. PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc  
  395. endif  
  396. else    # 执行下面这个赋值语句  
  397. # 最终等于:-L /opt/gcc-arm-none-eabi-4_7-2013q1/bin/../lib/gcc/arm-none-eabi/4.7.3/armv7-ar/thumb -lgcc  
  398. PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc  
  399. endif  
  400. # 下面这个变量的值为:/home/tomato/u-boot-2013.10/arch/arm/lib/eabi_compat.o  -L /opt/gcc-arm-none-eabi-4_7-2013q1/bin/../lib/gcc/arm-none-eabi/4.7.3/armv7-ar/thumb -lgcc  
  401. PLATFORM_LIBS += $(PLATFORM_LIBGCC)  
  402. export PLATFORM_LIBS  
  403.   
  404. # Special flags for CPP when processing the linker script.  
  405. # Pass the version down so we can handle backwards compatibility  
  406. # on the fly.  
  407. # 下面这个变量值为:-include /home/tomato/u-boot-2013.10/include/u-boot/u-boot.lds.h -DCPUDIR=arch/arm/cpu/armv7  
  408. LDPPFLAGS += \  
  409.     -include $(TOPDIR)/include/u-boot/u-boot.lds.h \  
  410.     -DCPUDIR=$(CPUDIR) \  
  411.     $(shell $(LD) --version | \# 通过sed处理以后没有得到什么  
  412.       sed -ne 's/GNU ld version [09][09]\.[09][09].*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')  
  413.   
  414. __OBJS := $(subst $(obj),,$(OBJS)) # 去掉OBJS中的obj目录,但是obj为空  
  415. # 变量LIBBOARD = board/samsung/smdkc100/libsmdkc100.o  
  416. __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))  
  417.   
  418. #########################################################################  
  419. #########################################################################  
  420.   
  421. ifneq ($(CONFIG_BOARD_SIZE_LIMIT),) # 不成立  
  422. BOARD_SIZE_CHECK = \  
  423.     @actual=`wc -c $@ | awk '{print $$1}'`; \  
  424.     limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \  
  425.     if test 
    actualgt
    limit; then \  
  426.         echo "$@ exceeds file size limit:" >&2 ; \  
  427.         echo "  limit:  $$limit bytes" >&2 ; \  
  428.         echo "  actual: $$actual bytes" >&2 ; \  
  429.         echo "  excess: $$((actual - limit)) bytes" >&2; \  
  430.         exit 1; \  
  431.     fi  
  432. else  
  433. BOARD_SIZE_CHECK = #其值为空  
  434. endif  
  435.   
  436. # Always append ALL so that arch config.mk's can add custom ones  
  437. ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map  
  438.   
  439. ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin  
  440. ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin  
  441. # CONFIGZ_SPL是我们需要的,修改源码配置的时候补充  
  442. ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin  
  443. ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img  
  444. ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin  
  445. ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin  
  446. ifneq ($(CONFIG_SPL_TARGET),)  
  447. ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET))  
  448. endif  
  449.   
  450. # enable combined SPL/u-boot/dtb rules for tegra  
  451. ifneq ($(CONFIG_TEGRA),) # 不成立  
  452. ifeq ($(CONFIG_OF_SEPARATE),y)  
  453. ALL-y += $(obj)u-boot-dtb-tegra.bin  
  454. else  
  455. ALL-y += $(obj)u-boot-nodtb-tegra.bin  
  456. endif  
  457. endif  
  458.   
  459. all:        $(ALL-y) $(SUBDIR_EXAMPLES)  
  460.   
  461. $(obj)u-boot.dtb:   checkdtc $(obj)u-boot  
  462.         $(MAKE) -C dts binary  
  463.         mv $(obj)dts/dt.dtb $@  
  464.   
  465. $(obj)u-boot-dtb.bin:   $(obj)u-boot.bin $(obj)u-boot.dtb  
  466.         cat $^ >$@  
  467.   
  468. $(obj)u-boot.hex:   $(obj)u-boot  
  469.         $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@  
  470.   
  471. $(obj)u-boot.srec:  $(obj)u-boot  
  472.         $(OBJCOPY) -O srec $< $@  
  473.   
  474. $(obj)u-boot.bin:   $(obj)u-boot  
  475.         $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@  
  476.         $(BOARD_SIZE_CHECK)  
  477.   
  478. $(obj)u-boot.ldr:   $(obj)u-boot  
  479.         $(CREATE_LDR_ENV)  
  480.         $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)  
  481.         $(BOARD_SIZE_CHECK)  
  482.   
  483. $(obj)u-boot.ldr.hex:   $(obj)u-boot.ldr  
  484.         $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary  
  485.   
  486. $(obj)u-boot.ldr.srec:  $(obj)u-boot.ldr  
  487.         $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary  
  488.   
  489. #  
  490. # U-Boot entry point, needed for booting of full-blown U-Boot  
  491. # from the SPL U-Boot version.  
  492. #  
  493. ifndef CONFIG_SYS_UBOOT_START  
  494. CONFIG_SYS_UBOOT_START := 0  
  495. endif  
  496.   
  497. $(obj)u-boot.img:   $(obj)u-boot.bin  
  498.         $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \  
  499.         -O u-boot -a $(CONFIG_SYS_TEXT_BASE) \  
  500.         -e $(CONFIG_SYS_UBOOT_START) \  
  501.         -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \  
  502.             sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \  
  503.         -d $< $@  
  504.   
  505. $(obj)u-boot.imx: $(obj)u-boot.bin depend  
  506.         $(MAKE) -C $(SRCTREE)/arch/arm/imx-common $(OBJTREE)/u-boot.imx  
  507.   
  508. $(obj)u-boot.kwb:       $(obj)u-boot.bin  
  509.         $(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \  
  510.         -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@  
  511.   
  512. $(obj)u-boot.pbl:   $(obj)u-boot.bin  
  513.         $(obj)tools/mkimage -n $(CONFIG_PBLRCW_CONFIG) \  
  514.         -R $(CONFIG_PBLPBI_CONFIG) -T pblimage \  
  515.         -d $< $@  
  516.   
  517. $(obj)u-boot.sha1:  $(obj)u-boot.bin  
  518.         $(obj)tools/ubsha1 $(obj)u-boot.bin  
  519.   
  520. $(obj)u-boot.dis:   $(obj)u-boot  
  521.         $(OBJDUMP) -d $< > $@  
  522.   
  523. # $@ is output, $(1) and $(2) are inputs, $(3) is padded intermediate,  
  524. # $(4) is pad-to  
  525. SPL_PAD_APPEND = \  
  526.         $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(4) -I binary -O binary \  
  527.         $(1) $(obj)$(3); \  
  528.         cat $(obj)$(3) $(2) > $@; \  
  529.         rm $(obj)$(3)  
  530.   
  531. ifdef CONFIG_TPL  
  532. SPL_PAYLOAD := $(obj)tpl/u-boot-with-tpl.bin  
  533. else  
  534. SPL_PAYLOAD := $(obj)u-boot.bin  
  535. endif  
  536.   
  537. $(obj)u-boot-with-spl.bin: $(obj)spl/u-boot-spl.bin $(SPL_PAYLOAD)  
  538.         $(call SPL_PAD_APPEND,$<,$(SPL_PAYLOAD),spl/u-boot-spl-pad.bin,$(CONFIG_SPL_PAD_TO))  
  539.   
  540. $(obj)tpl/u-boot-with-tpl.bin: $(obj)tpl/u-boot-tpl.bin $(obj)u-boot.bin  
  541.         $(call SPL_PAD_APPEND,$<,$(obj)u-boot.bin,tpl/u-boot-tpl-pad.bin,$(CONFIG_TPL_PAD_TO))  
  542.   
  543. $(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin  
  544.         $(MAKE) -C $(SRCTREE)/arch/arm/imx-common \  
  545.             $(OBJTREE)/u-boot-with-spl.imx  
  546.   
  547. $(obj)u-boot-with-nand-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin  
  548.         $(MAKE) -C $(SRCTREE)/arch/arm/imx-common \  
  549.             $(OBJTREE)/u-boot-with-nand-spl.imx  
  550.   
  551. $(obj)u-boot.ubl:       $(obj)u-boot-with-spl.bin  
  552.         $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \  
  553.         -e $(CONFIG_SYS_TEXT_BASE) -d $< $(obj)u-boot.ubl  
  554.   
  555. $(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.img  
  556.         $(obj)tools/mkimage -s -n $(if $(CONFIG_AIS_CONFIG_FILE),$(CONFIG_AIS_CONFIG_FILE),"/dev/null") \  
  557.             -T aisimage \  
  558.             -e $(CONFIG_SPL_TEXT_BASE) \  
  559.             -d $(obj)spl/u-boot-spl.bin \  
  560.             $(obj)spl/u-boot-spl.ais  
  561.         $(OBJCOPY) ${OBJCFLAGS} -I binary \  
  562.             --pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \  
  563.             $(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais  
  564.         cat $(obj)spl/u-boot-spl-pad.ais $(obj)u-boot.img > \  
  565.             $(obj)u-boot.ais  
  566.   
  567.   
  568. $(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin  
  569.         $(MAKE) -C $(SRCTREE)/$(CPUDIR)/$(SOC)/ $(OBJTREE)/u-boot.sb  
  570.   
  571. # On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.  
  572. # Both images are created using mkimage (crc etc), so that the ROM  
  573. # bootloader can check its integrity. Padding needs to be done to the  
  574. # SPL image (with mkimage header) and not the binary. Otherwise the resulting image  
  575. # which is loaded/copied by the ROM bootloader to SRAM doesn't fit.  
  576. # The resulting image containing both U-Boot images is called u-boot.spr  
  577. $(obj)u-boot.spr:   $(obj)u-boot.img $(obj)spl/u-boot-spl.bin  
  578.         $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \  
  579.         -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER \  
  580.         -d $(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl.img  
  581.         tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_SPL_PAD_TO) \  
  582.             of=$(obj)spl/u-boot-spl-pad.img 2>/dev/null  
  583.         dd if=$(obj)spl/u-boot-spl.img of=$(obj)spl/u-boot-spl-pad.img \  
  584.             conv=notrunc 2>/dev/null  
  585.         cat $(obj)spl/u-boot-spl-pad.img $(obj)u-boot.img > $@  
  586.   
  587. ifneq ($(CONFIG_TEGRA),)  
  588. $(obj)u-boot-nodtb-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin  
  589.         $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin  
  590.         cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@  
  591.         rm $(obj)spl/u-boot-spl-pad.bin  
  592.   
  593. ifeq ($(CONFIG_OF_SEPARATE),y)  
  594. $(obj)u-boot-dtb-tegra.bin: $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb  
  595.         cat $(obj)u-boot-nodtb-tegra.bin $(obj)u-boot.dtb > $@  
  596. endif  
  597. endif  
  598.   
  599. $(obj)u-boot-img.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img  
  600.         cat $(obj)spl/u-boot-spl.bin $(obj)u-boot.img > $@  
  601.   
  602. # PPC4xx needs the SPL at the end of the image, since the reset vector  
  603. # is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target  
  604. # and need to introduce a new build target with the full blown U-Boot  
  605. # at the start padded up to the start of the SPL image. And then concat  
  606. # the SPL image to the end.  
  607. $(obj)u-boot-img-spl-at-end.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.img  
  608.         tr "\000" "\377" < /dev/zero | dd ibs=1 count=$(CONFIG_UBOOT_PAD_TO) \  
  609.             of=$(obj)u-boot-pad.img 2>/dev/null  
  610.         dd if=$(obj)u-boot.img of=$(obj)u-boot-pad.img \  
  611.             conv=notrunc 2>/dev/null  
  612.         cat $(obj)u-boot-pad.img $(obj)spl/u-boot-spl.bin > $@  
  613.   
  614. ifeq ($(CONFIG_SANDBOX),y)  
  615. GEN_UBOOT = \  
  616.         cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \  
  617.             -Wl,--start-group $(__LIBS) -Wl,--end-group \  
  618.             $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot  
  619. else  
  620. GEN_UBOOT = \  
  621.         cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \  
  622.             $(__OBJS) \  
  623.             --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \  
  624.             -Map u-boot.map -o u-boot  
  625. endif  
  626.   
  627. $(obj)u-boot:   depend \  
  628.         $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds  
  629.         $(GEN_UBOOT)  
  630. ifeq ($(CONFIG_KALLSYMS),y)  
  631.         smap=`$(call SYSTEM_MAP,$(obj)u-boot) | \  
  632.             awk '
    2 ~ /[tTwW]/ {printf
    1 $$3 "\\\\000"}'` ; \  
  633.         $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \  
  634.             -c common/system_map.c -o $(obj)common/system_map.o  
  635.         $(GEN_UBOOT) $(obj)common/system_map.o  
  636. endif  
  637.   
  638. $(OBJS):    depend  
  639.         $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))  
  640.   
  641. $(LIBS):    depend $(SUBDIR_TOOLS)  
  642.         $(MAKE) -C $(dir $(subst $(obj),,$@))  
  643.   
  644. $(LIBBOARD):    depend $(LIBS)  
  645.         $(MAKE) -C $(dir $(subst $(obj),,$@))  
  646.   
  647. $(SUBDIRS): depend  
  648.         $(MAKE) -C $@ all  
  649.   
  650. $(SUBDIR_EXAMPLES): $(obj)u-boot  
  651.   
  652. $(LDSCRIPT):    depend  
  653.         $(MAKE) -C $(dir $@) $(notdir $@)  
  654.   
  655. $(obj)u-boot.lds: $(LDSCRIPT)  
  656.         $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$< >$@  
  657.   
  658. nand_spl:   $(TIMESTAMP_FILE) $(VERSION_FILE) depend  
  659.         $(MAKE) -C nand_spl/board/$(BOARDDIR) all  
  660.   
  661. $(obj)u-boot-nand.bin:  nand_spl $(obj)u-boot.bin  
  662.         cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin  
  663.   
  664. $(obj)spl/u-boot-spl.bin:   $(SUBDIR_TOOLS) depend  
  665.         $(MAKE) -C spl all  
  666.   
  667. $(obj)tpl/u-boot-tpl.bin:   $(SUBDIR_TOOLS) depend  
  668.         $(MAKE) -C spl all CONFIG_TPL_BUILD=y  
  669.   
  670. updater:  
  671.         $(MAKE) -C tools/updater all  
  672.   
  673. # Explicitly make _depend in subdirs containing multiple targets to prevent  
  674. # parallel sub-makes creating .depend files simultaneously.  
  675. depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \  
  676.         $(obj)include/spl-autoconf.mk \  
  677.         $(obj)include/tpl-autoconf.mk \  
  678.         $(obj)include/autoconf.mk \  
  679.         $(obj)include/generated/generic-asm-offsets.h \  
  680.         $(obj)include/generated/asm-offsets.h  
  681.         for dir in $(SUBDIRS) $(CPUDIR) $(LDSCRIPT_MAKEFILE_DIR) ; do \  
  682.             $(MAKE) -C $$dir _depend ; done  
  683.   
  684. TAG_SUBDIRS = $(SUBDIRS)  
  685. TAG_SUBDIRS += $(dir $(__LIBS))  
  686. TAG_SUBDIRS += include  
  687.   
  688. FIND := find  
  689. FINDFLAGS := -L  
  690.   
  691. checkstack:  
  692.         $(CROSS_COMPILE)objdump -d $(obj)u-boot \  
  693.             `$(FIND) $(obj) -name u-boot-spl -print` | \  
  694.             perl $(src)tools/checkstack.pl $(ARCH)  
  695.   
  696. tags ctags:  
  697.         ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \  
  698.                         -name '*.[chS]' -print`  
  699.   
  700. etags:  
  701.         etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \  
  702.                         -name '*.[chS]' -print`  
  703. cscope:  
  704.         $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \  
  705.                         cscope.files  
  706.         cscope -b -q -k  
  707.   
  708. SYSTEM_MAP = \  
  709.         $(NM) $1 | \  
  710.         grep -v 'compiled\|\.o$$\|[aUw]\|\.\.ng$$\|LASH[RL]DI' | \  
  711.         LC_ALL=C sort  
  712. $(obj)System.map:   $(obj)u-boot  
  713.         @$(call SYSTEM_MAP,$<) > $(obj)System.map  
  714.   
  715. checkthumb:  
  716.     @if test $(call cc-version) -lt 0404; then \  
  717.         echo -n '*** Your GCC does not produce working '; \  
  718.         echo 'binaries in THUMB mode.'; \  
  719.         echo '*** Your board is configured for THUMB mode.'; \  
  720.         false; \  
  721.     fi  
  722.   
  723. # GCC 3.x is reported to have problems generating the type of relocation  
  724. # that U-Boot wants.  
  725. # See http://lists.denx.de/pipermail/u-boot/2012-September/135156.html  
  726. checkgcc4:  
  727.     @if test $(call cc-version) -lt 0400; then \  
  728.         echo -n '*** Your GCC is too old, please upgrade to GCC 4.x or newer'; \  
  729.         false; \  
  730.     fi  
  731.   
  732. checkdtc:  
  733.     @if test $(call dtc-version) -lt 0104; then \  
  734.         echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \  
  735.         false; \  
  736.     fi  
  737.   
  738. #  
  739. # Auto-generate the autoconf.mk file (which is included by all makefiles)  
  740. #  
  741. # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.  
  742. # the dep file is only include in this top level makefile to determine when  
  743. # to regenerate the autoconf.mk file.  
  744. $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h  
  745.     @$(XECHO) Generating $@ ; \  
  746.     set -e ; \  
  747.     : Generate the dependancies ; \  
  748.     $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \  
  749.         -MQ $(obj)include/autoconf.mk include/common.h > $@  
  750.   
  751. $(obj)include/autoconf.mk: $(obj)include/config.h  
  752.     @$(XECHO) Generating $@ ; \  
  753.     set -e ; \  
  754.     : Extract the config macros ; \  
  755.     $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \  
  756.         sed -n -f tools/scripts/define2mk.sed > $@.tmp && \  
  757.     mv $@.tmp $@  
  758.   
  759. # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)  
  760. $(obj)include/tpl-autoconf.mk: $(obj)include/config.h  
  761.     @$(XECHO) Generating $@ ; \  
  762.     set -e ; \  
  763.     : Extract the config macros ; \  
  764.     $(CPP) $(CFLAGS) -DCONFIG_TPL_BUILD  -DCONFIG_SPL_BUILD\  
  765.             -DDO_DEPS_ONLY -dM include/common.h | \  
  766.     sed -n -f tools/scripts/define2mk.sed > $@.tmp && \  
  767.     mv $@.tmp $@  
  768.   
  769. $(obj)include/spl-autoconf.mk: $(obj)include/config.h  
  770.     @$(XECHO) Generating $@ ; \  
  771.     set -e ; \  
  772.     : Extract the config macros ; \  
  773.     $(CPP) $(CFLAGS) -DCONFIG_SPL_BUILD -DDO_DEPS_ONLY -dM include/common.h | \  
  774.     sed -n -f tools/scripts/define2mk.sed > $@.tmp && \  
  775.     mv $@.tmp $@  
  776.   
  777. $(obj)include/generated/generic-asm-offsets.h:  $(obj)include/autoconf.mk.dep \  
  778.     $(obj)include/spl-autoconf.mk \  
  779.     $(obj)include/tpl-autoconf.mk \  
  780.     $(obj)lib/asm-offsets.s  
  781.     @$(XECHO) Generating $@  
  782.     tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@  
  783.   
  784. $(obj)lib/asm-offsets.s:    $(obj)include/autoconf.mk.dep \  
  785.     $(obj)include/spl-autoconf.mk \  
  786.     $(obj)include/tpl-autoconf.mk \  
  787.     $(src)lib/asm-offsets.c  
  788.     @mkdir -p $(obj)lib  
  789.     $(CC) -DDO_DEPS_ONLY \  
  790.         $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \  
  791.         -o $@ $(src)lib/asm-offsets.c -c -S  
  792.   
  793. $(obj)include/generated/asm-offsets.h:  $(obj)include/autoconf.mk.dep \  
  794.     $(obj)include/spl-autoconf.mk \  
  795.     $(obj)include/tpl-autoconf.mk \  
  796.     $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s  
  797.     @$(XECHO) Generating $@  
  798.     tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@  
  799.   
  800. $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s:   $(obj)include/autoconf.mk.dep \  
  801.     $(obj)include/spl-autoconf.mk \  
  802.     $(obj)include/tpl-autoconf.mk  
  803.     @mkdir -p $(obj)$(CPUDIR)/$(SOC)  
  804.     if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \  
  805.         $(CC) -DDO_DEPS_ONLY \  
  806.         $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \  
  807.             -o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \  
  808.     else \  
  809.         touch $@; \  
  810.     fi  
  811.   
  812. #########################################################################  
  813. else    # !config.mk  
  814. all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \  
  815. $(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \  
  816. $(filter-out tools,$(SUBDIRS)) \  
  817. updater depend dep tags ctags etags cscope $(obj)System.map:  
  818.     @echo "System not configured - see README" >&2  
  819.     @ exit 1  
  820.   
  821. tools: $(VERSION_FILE) $(TIMESTAMP_FILE)  
  822.     $(MAKE) -C $@ all  
  823. endif   # config.mk  
  824.   
  825. # ARM relocations should all be R_ARM_RELATIVE.  
  826. checkarmreloc: $(obj)u-boot  
  827.     @if test "R_ARM_RELATIVE" != \  
  828.         "`$(CROSS_COMPILE)readelf -r $< | cut -d ' ' -f 4 | grep R_ARM | sort -u`"; \  
  829.         then echo "$< contains relocations other than \  
  830.         R_ARM_RELATIVE"; false; fi  
  831.   
  832. $(VERSION_FILE):  
  833.         @mkdir -p $(dir $(VERSION_FILE))  
  834.         @( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \  
  835.            printf '#define PLAIN_VERSION "%s%s"\n' \  
  836.             "$(U_BOOT_VERSION)" "$${localvers}" ; \  
  837.            printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \  
  838.             "$(U_BOOT_VERSION)" "$${localvers}" ; \  
  839.         ) > $@.tmp  
  840.         @( printf '#define CC_VERSION_STRING "%s"\n' \  
  841.          '$(shell $(CC) --version | head -n 1)' )>>  $@.tmp  
  842.         @( printf '#define LD_VERSION_STRING "%s"\n' \  
  843.          '$(shell $(LD) -v | head -n 1)' )>>  $@.tmp  
  844.         @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@  
  845.   
  846. $(TIMESTAMP_FILE):  
  847.         @mkdir -p $(dir $(TIMESTAMP_FILE))  
  848.         @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp  
  849.         @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp  
  850.         @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@  
  851.   
  852. easylogo env gdb:  
  853.     $(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION}  
  854. gdbtools: gdb  
  855.   
  856. xmldocs pdfdocs psdocs htmldocs mandocs: tools/kernel-doc/docproc  
  857.     $(MAKE) U_BOOT_VERSION=$(U_BOOT_VERSION) -C doc/DocBook/ $@  
  858.   
  859. tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE)  
  860.     $(MAKE) -C tools HOST_TOOLS_ALL=y  
  861.   
  862. .PHONY : CHANGELOG  
  863. CHANGELOG:  
  864.     git log --no-merges U-Boot-1_1_5.. | \  
  865.     unexpand -a | sed -e 's/\s\s*$$//' > $@  
  866.   
  867. include/license.h: tools/bin2header COPYING  
  868.     cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h  
  869. #########################################################################  
  870.   
  871. unconfig:  
  872.     @rm -f $(obj)include/config.h $(obj)include/config.mk \  
  873.         $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \  
  874.         $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \  
  875.         $(obj)include/spl-autoconf.mk \  
  876.         $(obj)include/tpl-autoconf.mk  
  877. # 每次执行make xxx_config时,都会执行上面的rm命令  
  878. %_config::  unconfig  
  879.     # $(@:_config=)即把smdkc100_config替换成smdkc100,调用以后执行过程见下一篇文档~  
  880.     @$(MKCONFIG) -A $(@:_config=)  
  881.   
  882. sinclude $(obj).boards.depend  
  883. $(obj).boards.depend:   boards.cfg  
  884.     @awk '(NF && 
    1 !~ /^#/) { print
    7 ": " 
    7"config;
    (MAKE)" }' $< > $@  
  885.   
  886. #  
  887. # Functions to generate common board directory names  
  888. #  
  889. lcname  = $(shell echo $(1) | sed -e 's/._config/\L\1/')  
  890. ucname  = $(shell echo $(1) | sed -e 's/._config/\U\1/')  
  891.   
  892. #########################################################################  
  893. #########################################################################  
  894.   
  895. clean:  
  896.     @rm -f $(obj)examples/standalone/82559_eeprom             \  
  897.            $(obj)examples/standalone/atmel_df_pow2            \  
  898.            $(obj)examples/standalone/eepro100_eeprom          \  
  899.            $(obj)examples/standalone/hello_world              \  
  900.            $(obj)examples/standalone/interrupt            \  
  901.            $(obj)examples/standalone/mem_to_mem_idma2intr         \  
  902.            $(obj)examples/standalone/sched                \  
  903.            $(obj)examples/standalone/smc911{11,x}_eeprom          \  
  904.            $(obj)examples/standalone/test_burst           \  
  905.            $(obj)examples/standalone/timer  
  906.     @rm -f $(obj)examples/api/demo{,.bin}  
  907.     @rm -f $(obj)tools/bmp_logo    $(obj)tools/easylogo/easylogo  \  
  908.            $(obj)tools/env/{fw_printenv,fw_setenv}            \  
  909.            $(obj)tools/envcrc                     \  
  910.            $(obj)tools/gdb/{astest,gdbcont,gdbsend}           \  
  911.            $(obj)tools/gen_eth_addr    $(obj)tools/img2srec       \  
  912.            $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk     \  
  913.            $(obj)tools/mk{$(BOARD),}spl               \  
  914.            $(obj)tools/mxsboot                    \  
  915.            $(obj)tools/ncb         $(obj)tools/ubsha1         \  
  916.            $(obj)tools/kernel-doc/docproc                 \  
  917.            $(obj)tools/proftool  
  918.     @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}    \  
  919.            $(obj)board/matrix_vision/*/bootscript.img         \  
  920.            $(obj)board/voiceblue/eeprom                   \  
  921.            $(obj)u-boot.lds                       \  
  922.            $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs]      \  
  923.            $(obj)arch/blackfin/cpu/init.{lds,elf}  
  924.     @rm -f $(obj)include/bmp_logo.h  
  925.     @rm -f $(obj)include/bmp_logo_data.h  
  926.     @rm -f $(obj)lib/asm-offsets.s  
  927.     @rm -f $(obj)include/generated/asm-offsets.h  
  928.     @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s  
  929.     @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)  
  930.     @$(MAKE) -s -C doc/DocBook/ cleandocs  
  931.     @find $(OBJTREE) -type f \  
  932.         \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \  
  933.         -o -name '*.o'  -o -name '*.a' -o -name '*.exe' \  
  934.         -o -name '*.cfgtmp' \) -print \  
  935.         | xargs rm -f  
  936.   
  937. # Removes everything not needed for testing u-boot  
  938. tidy:   clean  
  939.     @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f  
  940.   
  941. clobber:    tidy  
  942.     @find $(OBJTREE) -type f \( -name '*.srec' \  
  943.         -o -name '*.bin' -o -name u-boot.img \) \  
  944.         -print0 | xargs -0 rm -f  
  945.     @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \  
  946.         $(obj)cscope.* $(obj)*.*~  
  947.     @rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)  
  948.     @rm -f $(obj)u-boot.kwb  
  949.     @rm -f $(obj)u-boot.pbl  
  950.     @rm -f $(obj)u-boot.imx  
  951.     @rm -f $(obj)u-boot-with-spl.imx  
  952.     @rm -f $(obj)u-boot-with-nand-spl.imx  
  953.     @rm -f $(obj)u-boot.ubl  
  954.     @rm -f $(obj)u-boot.ais  
  955.     @rm -f $(obj)u-boot.dtb  
  956.     @rm -f $(obj)u-boot.sb  
  957.     @rm -f $(obj)u-boot.bd  
  958.     @rm -f $(obj)u-boot.spr  
  959.     @rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map}  
  960.     @rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}  
  961.     @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}  
  962.     @rm -f $(obj)spl/u-boot-spl.lds  
  963.     @rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map}  
  964.     @rm -f $(obj)tpl/u-boot-spl.lds  
  965.     @rm -f $(obj)MLO MLO.byteswap  
  966.     @rm -f $(obj)SPL  
  967.     @rm -f $(obj)tools/xway-swap-bytes  
  968.     @rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c  
  969.     @rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c  
  970.     @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm  
  971.     @rm -fr $(obj)include/generated  
  972.     @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f  
  973.     @rm -f $(obj)dts/*.tmp  
  974.     @rm -f $(obj)spl/u-boot-spl{,-pad}.ais  
  975.   
  976. mrproper \  
  977. distclean:  clobber unconfig  
  978. ifneq ($(OBJTREE),$(SRCTREE))  
  979.     rm -rf $(obj)*  
  980. endif  
  981.   
  982. backup:  
  983.     F=`basename $(TOPDIR)` ; cd .. ; \  
  984.     gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F  
  985.   
  986. #########################################################################