【s5p4418嵌入式学习】u-boot学习之makefile注释07
来源:互联网 发布:秒赞网哪一个源码好 编辑:程序博客网 时间:2024/05/21 16:05
作者: Linux-小企鹅
博客地址:http://blog.csdn.net/u012319379/article/details/77882450
这一篇博客真的很耗时间,Makefile中需要很多shell脚本的知识,针对于u-boot这样一个大的工程管理规则需要分析的很具体的话估计是神一样的级别,网上大体的u-boot Makefile文件分析大多是都停留在s3c2440,s3c6410和210上面,个人感觉虽然Makefile大体都一样,但是s5p4418还是和他们有区别,所以就有了写这一篇博客的意愿,Makefile内容太多我也理解不是很多,希望新手选择性阅读加上自己的思考,高手能够出一篇完全解读的让我们菜菜膜拜学习下。
作为一篇博客是为了记录记得学习心得,不同阶段的理解和能力不一致。写作上有可能或有错误的地方,希望看到博客的博友参考性阅读。
s5p4418 u-boot-2014.07 Makefile文件注释
##版权2000-2013# (C) Copyright 2000-2013#作者 职位 邮箱# Wolfgang Denk, DENX Software Engineering, wd@denx.de.## license协议# SPDX-License-Identifier: GPL-2.0+#VERSION = 2014PATCHLEVEL = 07SUBLEVEL =EXTRAVERSION =NAME =# 文档# *DOCUMENTATION*# 了解典型目标列表执行make help 命令# To see a list of typical targets execute "make help"# 更多的信息可以查看本地的./README文件# More info can be located in ./README# 文档的注释针对开发者# Comments in this file are targeted only to the developer, do not# 期待了解编译内核读这个文件# expect to learn how to build the kernel reading this file.# 请勿# Do not:# o 使用make编译规则和变量# o use make's built-in rules and variables# o 提高性能,避免难于调试的行为# (this increases performance and avoids hard-to-debug behaviour);# o 打印 字符。。。# o print "Entering directory ...";MAKEFLAGS += -rR --no-print-directory# 设置依赖避免古怪的字符# Avoid funny character set dependenciesunexport LC_ALLLC_COLLATE=CLC_NUMERIC=Cexport LC_COLLATE LC_NUMERIC# 我们使用递归编译,我们需要做少量的工作得到正确的顺序# We are using a recursive build, so we need to do a little thinking# to get the ordering right.## Most importantly: sub-Makefiles should only ever modify files in# their own directory. If in some directory we have a dependency on# a file in another dir (which doesn't happen often, but it's often# unavoidable when linking the built-in.o targets which finally# turn into vmlinux), we will call a sub make in that other dir, and# after that we are sure that everything which is in that other dir# is now up to date.## The only cases where we need to modify files which have global# effects are thus separated out and done before the recursive# descending is started. They are now explicitly listed as the# prepare rule.# To put more focus on warnings, be less verbose as default# 使用 make V=1查看更全的命令# Use 'make V=1' to see the full commandsifeq ("$(origin V)", "command line") KBUILD_VERBOSE = $(V)endififndef KBUILD_VERBOSE KBUILD_VERBOSE = 0 #可以直接这里改0,1====0,正常,1,查看更全的命令行信息endif# Call a source code checker (by default, "sparse") as part of the# C compilation.## Use 'make C=1' to enable checking of only re-compiled files.# Use 'make C=2' to enable checking of *all* source files, regardless# of whether they are re-compiled or not.## See the file "Documentation/sparse.txt" for more details, including# where to get the "sparse" utility.#使用make C=1使能检查预编译文件#使用make C=2使能检查所有的文件ifeq ("$(origin C)", "command line") KBUILD_CHECKSRC = $(C)endififndef KBUILD_CHECKSRC KBUILD_CHECKSRC = 0 #可以直接改0,1,2endif# Use make M=dir to specify directory of external module to build# Old syntax make ... SUBDIRS=$PWD is still supported# Setting the environment variable KBUILD_EXTMOD take precedence# 旧语法定义SUBDIRS指定外部模块ifdef SUBDIRS KBUILD_EXTMOD ?= $(SUBDIRS)endif#新语法使用make M=?指定外部模块ifeq ("$(origin M)", "command line") KBUILD_EXTMOD := $(M)endif# kbuild supports saving output files in a separate directory.# To locate output files in a separate directory two syntaxes are supported.# In both cases the working directory must be the root of the kernel src.# 1) O=# Use "make O=dir/to/store/output/files/"## 2) Set KBUILD_OUTPUT# Set the environment variable KBUILD_OUTPUT to point to the directory# where the output files shall be placed.# export KBUILD_OUTPUT=dir/to/store/output/files/# make## The O= assignment takes precedence over the KBUILD_OUTPUT environment# variable.# KBUILD_SRC is set on invocation of make in OBJ directory# KBUILD_SRC is not intended to be used by the regular user (for now)ifeq ($(KBUILD_SRC),)# OK, Make called in directory where kernel src resides# Do we want to locate output files in a separate directory?# 使用make O=?指定编译输出目录ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O) endififeq ("$(origin W)", "command line") export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)endif# That's our default target when none is given on the command line# 伪目标PHONY := _all_all:# Cancel implicit rules on top Makefile# 在顶层Makefile中去除隐性的规则$(CURDIR)/Makefile Makefile: ;ifneq ($(KBUILD_OUTPUT),) #有指定编译输出目录# Invoke a second make in the output directory, passing relevant variables# check that the output directory actually existssaved-output := $(KBUILD_OUTPUT)# 根据指定的目录创建输出目录并返回目录路径KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ && /bin/pwd)# 检查目录创建成功与否,个人理解,理解为三目运算符, $(if $(KBUILD_OUTPUT),, \ $(error failed to create output directory "$(saved-output)"))# MAKECMDGOALS变量记录了命令行参数指定的终极目标列表,个人理解就是所有的目录都放在变量里面PHONY += $(MAKECMDGOALS) sub-make#这里 filter-out 是返回$(MAKECMDGOALS)中除了 Makefile _all sub-make 以外的 #其他文件$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make @:# FORCE是空依赖,个人理解就是sub-make的目标实现sub-make: FORCE # 如果KBUILD_VERBOSE=1就替换为空,如果为空就隐显执行make -C $(KBUILD_OUTPUT) $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ KBUILD_SRC=$(CURDIR) \ #指定模块编译的Makefile文件 KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ #过滤三个文件 $(filter-out _all sub-make,$(MAKECMDGOALS))# Leave processing to above invocation of make# 离开子目录make后skip-makefile := 1skip-makefile := 1endif # ifneq ($(KBUILD_OUTPUT),)endif # ifeq ($(KBUILD_SRC),)# We process the rest of the Makefile if this is the final invocation of make# 因为没有指定KBUILD_OUTPUT,所以这里会执行,(skip-makefile=0)ifeq ($(skip-makefile),)# If building an external module we do not care about the all: rule# but instead _all depend on modules# 伪目标集合PHONY += all# KBUILD_EXTMOD没有指定,所以指定_all目标依赖allifeq ($(KBUILD_EXTMOD),)_all: allelse_all: modulesendifsrctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) #如果KBUILD_SRC有赋值就用该值,没有就赋值CURDIR,就是防止前面if执行没有值objtree := $(CURDIR)src := $(srctree)obj := $(objtree)VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) #就是加入srctree和KBUILD_EXTMOD# 导出变量export srctree objtree VPATH# 指定mkconfig脚本路径MKCONFIG := $(srctree)/mkconfigexport MKCONFIG# Make sure CDPATH settings don't interfereunexport CDPATH########################################################################## 主机架构x86,arm,powerpc...HOSTARCH := $(shell uname -m | \ sed -e s/i.86/x86/ \ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ \ -e s/sa110/arm/ \ -e s/ppc64/powerpc/ \ -e s/ppc/powerpc/ \ -e s/macppc/powerpc/\ -e s/sh.*/sh/)# 主机,主机名转小写HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ sed -e 's/\(cygwin\).*/cygwin/') # 针对Windows系统,也没人用Windows编译export HOSTARCH HOSTOS# Deal with colliding definitions from tcsh etc.VENDOR=########################################################################## set default to nothing for native buildsifeq ($(HOSTARCH),$(ARCH))CROSS_COMPILE ?=endif# SHELL used by kbuild# 配置shell解析器,bash,bin/bash/,shCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi ; fi)#主机c编译器HOSTCC = gcc#主机cpp编译器HOSTCXX = g++#编译器编译指定参数 警告 优化等级2 等等,具体的可以百度HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointerHOSTCXXFLAGS = -O2# 这个是Windows平台,我们不考虑,没有谁会在Windows上编译,我没见过ifeq ($(HOSTOS),cygwin)HOSTCFLAGS += -ansiendif# Mac OS X / Darwin's C preprocessor is Apple specific. It# generates numerous errors and warnings. We want to bypass it# and use GNU C's cpp. To do this we pass the -traditional-cpp# option to the compiler. Note that the -traditional-cpp flag# DOES NOT have the same semantics as GNU C's flag, all it does# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.## Apple's linker is similar, thanks to the new 2 stage linking# multiple symbol definitions are treated as errors, hence the# -multiply_defined suppress option to turn off this error.##苹果电脑编译,高逼格搞不起不分析ifeq ($(HOSTOS),darwin)# get major and minor product version (e.g. '10' and '6' for Snow Leopard)DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.')DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.')os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)# Snow Leopards build environment has no longer restrictions as described aboveHOSTCC = $(call os_x_before, 10, 5, "cc", "gcc")HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp")HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")endif# Decide whether to build built-in, modular, or both.# Normally, just do built-in.KBUILD_MODULES :=KBUILD_BUILTIN := 1# If we have only "make modules", don't compile built-in objects.# When we're building modules with modversions, we need to consider# the built-in objects during the descend as well, in order to# make sure the checksums are up to date before we record them.ifeq ($(MAKECMDGOALS),modules) KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)endif# If we have "make <whatever> modules", compile modules# in addition to whatever we do anyway.# Just "make" or "make all" shall build modules as well# U-Boot does not need modules#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)# KBUILD_MODULES := 1#endif#ifeq ($(MAKECMDGOALS),)# KBUILD_MODULES := 1#endifexport KBUILD_MODULES KBUILD_BUILTINexport KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD# Beautify output# ---------------------------------------------------------------------------## Normally, we echo the whole command before executing it. By making# that echo $($(quiet)$(cmd)), we now have the possibility to set# $(quiet) to choose other forms of output instead, e.g.## quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<## If $(quiet) is empty, the whole command will be printed.# If it is set to "quiet_", only the short version will be printed.# If it is set to "silent_", nothing will be printed at all, since# the variable $(silent_cmd_cc_o_c) doesn't exist.## A simple variant is to prefix commands with $(Q) - that's useful# for commands that shall be hidden in non-verbose mode.## $(Q)ln $@ :<## If KBUILD_VERBOSE equals 0 then the above command will be hidden.# If KBUILD_VERBOSE equals 1 then the above command is displayed.# 如果KBUILD_VERBOSE = 0,命令行将隐藏# 如果KBUILD_VERBOSE = 1,命令行回显ifeq ($(KBUILD_VERBOSE),1) quiet = Q =else quiet=quiet_ Q = @endif# If the user is running make -s (silent mode), suppress echoing of# commands#make的版本ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) quiet=silent_endifelse # make-3.8xifneq ($(filter s% -s%,$(MAKEFLAGS)),) quiet=silent_endifendifexport quiet Q KBUILD_VERBOSE# Look for make include files relative to root of kernel src# 指定make的include目录MAKEFLAGS += --include-dir=$(srctree)# We need some generic definitions (do not try to remake the file).$(srctree)/scripts/Kbuild.include: ; #个人理解,检查文件是否存在include $(srctree)/scripts/Kbuild.include #包含该文件# Make variables (CC, etc...)# 编译器别名AS = $(CROSS_COMPILE)as# Always use GNU ldifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)LD = $(CROSS_COMPILE)ld.bfdelseLD = $(CROSS_COMPILE)ldendifCC = $(CROSS_COMPILE)gccCPP = $(CC) -EAR = $(CROSS_COMPILE)arNM = $(CROSS_COMPILE)nmLDR = $(CROSS_COMPILE)ldrSTRIP = $(CROSS_COMPILE)stripOBJCOPY = $(CROSS_COMPILE)objcopyOBJDUMP = $(CROSS_COMPILE)objdumpAWK = awkPERL = perlDTC = dtcCHECK = sparseCHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)KBUILD_CPPFLAGS := -D__KERNEL__KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ -Wno-format-security \ -fno-builtin -ffreestandingKBUILD_AFLAGS := -D__ASSEMBLY__# Read UBOOTRELEASE from include/config/uboot.release (if it exists)UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)# 导出变量export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSIONexport ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIRexport CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CCexport CPP AR NM LDR STRIP OBJCOPY OBJDUMPexport MAKE AWK PERLexport HOSTCXX HOSTCXXFLAGS DTC CHECK CHECKFLAGSexport KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGSexport KBUILD_CFLAGS KBUILD_AFLAGS# When compiling out-of-tree modules, put MODVERDIR in the module# tree rather than in the kernel tree. The kernel tree might# even be read-only.export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions# Files to ignore in find ... statementsexport RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ -name CVS -o -name .pc -o -name .hg -o -name .git \) \ -prune -oexport RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ --exclude CVS --exclude .pc --exclude .hg --exclude .git# ===========================================================================# Rules shared between *config targets and build targets# Basic helpers built in scripts/PHONY += scripts_basic# 这里有个Makefile文件,编译了一个.c文件scripts_basic: $(Q)$(MAKE) $(build)=scripts/basic $(Q)rm -f .tmp_quiet_recordmcount# To avoid any implicit rule to kick in, define an empty command.scripts/basic/%: scripts_basic ;PHONY += outputmakefile# outputmakefile generates a Makefile in the output directory, if using a# separate output directory. This allows convenient use of make in the# output directory.# 在输出目录生成一个Makefile文件,如果单独输出到目录,在输出目录中使用makeoutputmakefile:ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree) source $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)endif# To make sure we do not include .config for any of the *config targets# catch them early, and hand them over to scripts/kconfig/Makefile# It is allowed to specify more targets when calling make, including# mixing *config targets and build targets.# For example 'make oldconfig all'.# Detect when mixed targets is specified, and make a second invocation# of make so .config is not included in this case either (for *config).version_h := include/generated/version_autogenerated.htimestamp_h := include/generated/timestamp_autogenerated.hno-dot-config-targets := clean clobber mrproper distclean \ help %docs check% coccicheck \ ubootversion backup tools-onlyconfig-targets := 0mixed-targets := 0dot-config := 1ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) dot-config := 0 endifendif# 如果没有指定的KBUILD_EXTMOD,ifeq ($(KBUILD_EXTMOD),) ifneq ($(filter config %config,$(MAKECMDGOALS)),) config-targets := 1 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) mixed-targets := 1 endif endifendififeq ($(mixed-targets),1)# ===========================================================================# We're called with mixed targets (*config and build targets).# Handle them one by one.PHONY += $(MAKECMDGOALS) build-one-by-one$(MAKECMDGOALS): build-one-by-one @:build-one-by-one: $(Q)set -e; \ for i in $(MAKECMDGOALS); do \ $(MAKE) -f $(srctree)/Makefile $$i; \ #循环执行命令列表 doneelseifeq ($(config-targets),1)# ===========================================================================# *config targets only - make sure prerequisites are updated, and descend# in scripts/kconfig to make the *config target# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.# KBUILD_DEFCONFIG may point out an alternative default configuration# used for 'make defconfig'# 这边是分析make XXX_config的解析生成config.h%_config:: outputmakefile @$(MKCONFIG) -A $(@:_config=)else# ===========================================================================# Build targets only - this includes vmlinux, arch specific targets, clean# targets and others. In general all targets except *config targets.# load ARCH, BOARD, and CPU configuration# 加入*.mk文件-include include/config.mk# 判断是否存在.config,存在加载下列.mk文件ifeq ($(dot-config),1)# Read in config-include include/autoconf.mk-include include/autoconf.mk.dep# load other configurationinclude $(srctree)/config.mk# wildcard扩展通配符 #它被展开为已经存在的、使用空格分开的、匹配此模式的所有文件列表。#如果不存在任何符合此模式的文件,函数会忽略模式字符并返回空#个人理解,展开所有config.mk文件,不存在返回空,如果为空则打印错误ifeq ($(wildcard include/config.mk),)$(error "System not configured - see README")endif# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use# that (or fail if absent). Otherwise, search for a linker script in a# standard location.# 如果代码明确指定了LDSCRIPT或者CONFIG_SYS_LDSCRIPT,就使用# 没有看到定义,会执行ifndef LDSCRIPT #LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug ifdef CONFIG_SYS_LDSCRIPT # need to strip off double quotes # #define CONFIG_SYS_LDSCRIPT "arch/arm/cpu/slsiap/u-boot.lds" LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%) endifendif# If there is no specified link script, we look in a number of places for itifndef LDSCRIPT # 下面三个对LDSCRIPT进行扩展展开,检测是否存在"arch/arm/cpu/slsiap/u-boot.lds"文件,不存在重新指定 ifeq ($(wildcard $(LDSCRIPT)),) LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds endif ifeq ($(wildcard $(LDSCRIPT)),) LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot.lds endif ifeq ($(wildcard $(LDSCRIPT)),) LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot.lds endifendifelseendif # $(dot-config)KBUILD_CFLAGS += $(call cc-option, -mcpu=cortex-a9) # Add by jhkim for AARCH64KBUILD_CFLAGS += -Os #-fomit-frame-pointerifdef BUILD_TAGKBUILD_CFLAGS += -DBUILD_TAG='"$(BUILD_TAG)"'endifKBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)KBUILD_CFLAGS += -g# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format># option to the assembler.KBUILD_AFLAGS += -g# Report stack usage if supportedifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y) KBUILD_CFLAGS += -fstack-usageendifKBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)# turn jbsr into jsr for m68k# 不执行ifeq ($(ARCH),m68k)ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)KBUILD_AFLAGS += -Wa,-gstabs,-Sendifendif# Prohibit date/time macros, which would make the build non-deterministicKBUILD_CFLAGS += $(call cc-option,-Werror=date-time)# 指定代码端开始地址ifneq ($(CONFIG_SYS_TEXT_BASE),)KBUILD_CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)endifexport CONFIG_SYS_TEXT_BASE# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignmentsKBUILD_CPPFLAGS += $(KCPPFLAGS)KBUILD_AFLAGS += $(KAFLAGS)KBUILD_CFLAGS += $(KCFLAGS)# Use UBOOTINCLUDE when you must reference the include/ directory.# Needed to be compatible with the O= option# uboot的目录包含路径UBOOTINCLUDE := \ -Iinclude \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ -I$(srctree)/arch/$(ARCH)/includeNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)CHECKFLAGS += $(NOSTDINC_FLAGS)# FIX MEcpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ $(NOSTDINC_FLAGS)c_flags := $(KBUILD_CFLAGS) $(cpp_flags)########################################################################## U-Boot objects....order is important (i.e. start must be first)# 编译后需要链接的文件,start.o必须放在第一个head-y := $(CPUDIR)/start.ohead-$(CONFIG_4xx) += arch/powerpc/cpu/ppc4xx/resetvec.ohead-$(CONFIG_MPC85xx) += arch/powerpc/cpu/mpc85xx/resetvec.oHAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)libs-y += lib/libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/libs-y += $(CPUDIR)/ifdef SOClibs-y += $(CPUDIR)/$(SOC)/endiflibs-$(CONFIG_OF_EMBED) += dts/libs-y += arch/$(ARCH)/lib/libs-y += fs/libs-y += net/libs-y += disk/libs-y += drivers/libs-$(CONFIG_DM) += drivers/core/libs-y += drivers/dma/libs-y += drivers/gpio/libs-y += drivers/i2c/libs-y += drivers/input/libs-y += drivers/mmc/ifdef CONFIG_NAND_MTDlibs-y += drivers/mtd/libs-y += drivers/mtd/nand/libs-y += drivers/mtd/onenand/libs-y += drivers/mtd/spi/libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/endiflibs-y += drivers/net/libs-y += drivers/net/phy/libs-y += drivers/pci/libs-y += drivers/power/ \ drivers/power/fuel_gauge/ \ drivers/power/mfd/ \ drivers/power/pmic/ \ drivers/power/battery/libs-y += drivers/spi/libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/libs-y += drivers/serial/libs-y += drivers/usb/eth/libs-y += drivers/usb/gadget/libs-y += drivers/usb/host/libs-y += drivers/usb/musb/libs-y += drivers/usb/musb-new/libs-y += drivers/usb/phy/libs-y += drivers/usb/ulpi/libs-y += common/libs-y += lib/libfdt/libs-$(CONFIG_API) += api/libs-$(CONFIG_HAS_POST) += post/libs-y += test/libs-y += test/dm/libs-$(CONFIG_DM_DEMO) += drivers/demo/ifneq (,$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35 mxs vf610))libs-y += arch/$(ARCH)/imx-common/endiflibs-$(CONFIG_ARM) += arch/arm/cpu/libs-$(CONFIG_PPC) += arch/powerpc/cpu/libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)# 列表排序libs-y := $(sort $(libs-y))u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examplesu-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))libs-y := $(patsubst %/, %/built-in.o, $(libs-y))u-boot-init := $(head-y)u-boot-main := $(libs-y)# Add GCC libifdef CONFIG_USE_PRIVATE_LIBGCCifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.aelsePLATFORM_LIBGCC = -L $(CONFIG_USE_PRIVATE_LIBGCC) -lgccendifelsePLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgccendifPLATFORM_LIBS += $(PLATFORM_LIBGCC)export PLATFORM_LIBSexport PLATFORM_LIBGCC# Special flags for CPP when processing the linker script.# Pass the version down so we can handle backwards compatibility# on the fly.# 对链接脚本指定flag,# ld低版本的可以向后兼容,高版本也可以飞起来LDPPFLAGS += \ -include $(srctree)/include/u-boot/u-boot.lds.h \ -DCPUDIR=$(CPUDIR) \ $(shell $(LD) --version | \ sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')##################################################################################################################################################ifneq ($(CONFIG_BOARD_SIZE_LIMIT),)BOARD_SIZE_CHECK = \ @actual=`wc -c $@ | awk '{print $$1}'`; \ limit=`printf "%d" $(CONFIG_BOARD_SIZE_LIMIT)`; \ if test $$actual -gt $$limit; then \ echo "$@ exceeds file size limit:" >&2 ; \ echo " limit: $$limit bytes" >&2 ; \echo " actual: $$actual bytes" >&2 ; \ echo " excess: $$((actual - limit)) bytes" >&2; \ exit 1; \ fielseBOARD_SIZE_CHECK =endif# Statically apply RELA-style relocations (currently arm64 only)ifneq ($(CONFIG_STATIC_RELA),)# $(1) is u-boot ELF, $(2) is u-boot bin, $(3) is text base# 代码迁移DO_STATIC_RELA = \ start=$$($(NM) $(1) | grep __rel_dyn_start | cut -f 1 -d ' '); \end=$$($(NM) $(1) | grep __rel_dyn_end | cut -f 1 -d ' '); \ tools/relocate-rela $(2) $(3) $$start $$endelseDO_STATIC_RELA =endif# Always append ALL so that arch config.mk's can add custom onesALL-y += u-boot.srec u-boot.bin System.map binary_size_checkALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.binifeq ($(CONFIG_SPL_FSL_PBL),y)ALL-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.binelseALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pblendifALL-$(CONFIG_SPL) += spl/u-boot-spl.binALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.imgALL-$(CONFIG_TPL) += tpl/u-boot-tpl.binALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.binifeq ($(CONFIG_SPL_FRAMEWORK),y)ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.imgendifALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtbifneq ($(CONFIG_SPL_TARGET),)ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)endifALL-$(CONFIG_REMAKE_ELF) += u-boot.elf# enable combined SPL/u-boot/dtb rules for tegra# 针对的是Tegra,我们是armifneq ($(CONFIG_TEGRA),)ifeq ($(CONFIG_SPL),y)ifeq ($(CONFIG_OF_SEPARATE),y)ALL-y += u-boot-dtb-tegra.binelseALL-y += u-boot-nodtb-tegra.binendifendifendifLDFLAGS_u-boot += $(LDFLAGS_FINAL)#指定代码段的基地址ifneq ($(CONFIG_SYS_TEXT_BASE),)LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)endifquiet_cmd_objcopy = OBJCOPY $@cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@quiet_cmd_mkimage = MKIMAGE $@cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ $(if $(KBUILD_VERBOSE:1=), >/dev/null)quiet_cmd_cat = CAT $@cmd_cat = cat $(filter-out $(PHONY), $^) > $@append = cat $(filter-out $< $(PHONY), $^) >> $@quiet_cmd_pad_cat = CAT $@cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@# 编译目标,all: $(ALL-y)PHONY += dtbsdtbs dts/dt.dtb: checkdtc u-boot $(Q)$(MAKE) $(build)=dts dtbsu-boot-dtb.bin: u-boot.bin dts/dt.dtb FORCE $(call if_changed,cat)%.imx: %.bin $(Q)$(MAKE) $(build)=arch/arm/imx-common $@quiet_cmd_copy = COPY $@ cmd_copy = cp $< $@u-boot.dtb: dts/dt.dtb $(call cmd,copy)OBJCOPYFLAGS_u-boot.hex := -O ihexOBJCOPYFLAGS_u-boot.srec := -O srec# 生成目标u-boot.srec,u-boot.hex u-boot.srec: u-boot FORCE $(call if_changed,objcopy)OBJCOPYFLAGS_u-boot.bin := -O binarybinary_size_check: u-boot.bin System.map FORCE @file_size=`stat -c %s u-boot.bin` ; \ map_size=$(shell cat System.map | \ awk '/_image_copy_start/ {start = $$1} /_image_binary_end/ {end = $$1} END {if (start != "" && end != "") print "ibase=16; " toupper(end) " - " toupper(start)}' \| bc); \if [ "" != "$$map_size" ]; then \ if test $$map_size -ne $$file_size; then \ echo "System.map shows a binary size of $$map_size" >&2 ; \echo " but u-boot.bin shows $$file_size" >&2 ; \ exit 1; \ fi \ fiu-boot.bin: u-boot FORCE $(call if_changed,objcopy) $(call DO_STATIC_RELA,$<,$@,$(CONFIG_SYS_TEXT_BASE)) $(BOARD_SIZE_CHECK) cp mkuboot_4418 mkuboot ./nx_bingen-4418 -t 2ndboot -d other -o 2ndboot.bin -i 2ndboot_sdmmc_4418.bin -n nsih.txt -l 0xffff0000 -e 0xffff0000 ./create_uboot 2ndboot.bin u-boot.bin u-boot-iTOP-4418.binu-boot.ldr: u-boot $(CREATE_LDR_ENV) $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS) $(BOARD_SIZE_CHECK)OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihexOBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srecu-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE $(call if_changed,objcopy)## U-Boot entry point, needed for booting of full-blown U-Boot# from the SPL U-Boot version.#ifndef CONFIG_SYS_UBOOT_STARTCONFIG_SYS_UBOOT_START := 0endifMKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \ -T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimageu-boot.img u-boot.kwb u-boot.pbl: u-boot.bin FORCE $(call if_changed,mkimage)MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)u-boot-dtb.img: u-boot-dtb.bin FORCE $(call if_changed,mkimage)u-boot.sha1: u-boot.bin tools/ubsha1 u-boot.binu-boot.dis: u-boot $(OBJDUMP) -d $< > $@ifdef CONFIG_TPLSPL_PAYLOAD := tpl/u-boot-with-tpl.binelseSPL_PAYLOAD := u-boot.binendifOBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ --pad-to=$(CONFIG_SPL_PAD_TO)u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) FORCE $(call if_changed,pad_cat)OBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \ --pad-to=$(CONFIG_TPL_PAD_TO)tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE $(call if_changed,pad_cat)SPL: spl/u-boot-spl.bin FORCE $(Q)$(MAKE) $(build)=arch/arm/imx-common $@u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE $(Q)$(MAKE) $(build)=arch/arm/imx-common $@MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE)u-boot.ubl: u-boot-with-spl.bin FORCE $(call if_changed,mkimage)MKIMAGEFLAGS_u-boot-spl.ais = -s -n $(if $(CONFIG_AIS_CONFIG_FILE), \ $(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \ -T aisimage -e $(CONFIG_SPL_TEXT_BASE)spl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE $(call if_changed,mkimage)OBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)u-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE $(call if_changed,pad_cat)u-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sbu-boot.sb: u-boot.bin spl/u-boot-spl.bin $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.# Both images are created using mkimage (crc etc), so that the ROM# bootloader can check its integrity. Padding needs to be done to the# SPL image (with mkimage header) and not the binary. Otherwise the resulting image# which is loaded/copied by the ROM bootloader to SRAM doesn't fit.# The resulting image containing both U-Boot images is called u-boot.sprMKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \ -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADERspl/u-boot-spl.img: spl/u-boot-spl.bin FORCE $(call if_changed,mkimage)OBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ --gap-fill=0xffu-boot.spr: spl/u-boot-spl.img u-boot.img FORCE $(call if_changed,pad_cat)MKIMAGEFLAGS_u-boot-spl.gph = -A $(ARCH) -T gpimage -C none \ -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n SPLspl/u-boot-spl.gph: spl/u-boot-spl.bin FORCE $(call if_changed,mkimage)OBJCOPYFLAGS_u-boot-spi.gph = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ --gap-fill=0u-boot-spi.gph: spl/u-boot-spl.gph u-boot.img FORCE $(call if_changed,pad_cat)ifneq ($(CONFIG_SUNXI),)OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \ --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xffu-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE $(call if_changed,pad_cat)endififneq ($(CONFIG_TEGRA),)OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot.bin FORCE $(call if_changed,pad_cat)ifeq ($(CONFIG_OF_SEPARATE),y)u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin dts/dt.dtb FORCE $(call if_changed,cat)endifendifu-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE $(call if_changed,cat)#Add a target to create boot binary having SPL binary in PBI format#concatenated with u-boot binary. It is need by PowerPC SoC having#internal SRAM <= 512KB.MKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimagespl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE $(call if_changed,mkimage)OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ --gap-fill=0xffu-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl u-boot.bin FORCE $(call if_changed,pad_cat)# PPC4xx needs the SPL at the end of the image, since the reset vector# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target# and need to introduce a new build target with the full blown U-Boot# at the start padded up to the start of the SPL image. And then concat# the SPL image to the end.OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \ --pad-to=$(CONFIG_UBOOT_PAD_TO) --gap-fill=0xffu-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE $(call if_changed,pad_cat)# Create a new ELF from a raw binary file. This is useful for arm64# where static relocation needs to be performed on the raw binary,# but certain simulators only accept an ELF file (but don't do the# relocation).# FIXME refactor dts/Makefile to share target/arch detectionu-boot.elf: u-boot.bin @$(OBJCOPY) -B aarch64 -I binary -O elf64-littleaarch64 \ $< u-boot-elf.o @$(LD) u-boot-elf.o -o $@ \ --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)# Rule to link u-boot# May be overridden by arch/$(ARCH)/config.mkquiet_cmd_u-boot__ ?= LD $@ cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ -T u-boot.lds $(u-boot-init) \ --start-group $(u-boot-main) --end-group \ $(PLATFORM_LIBS) -Map u-boot.map# 生成u-boot,需要u-boot-init,u-boot-main, u-boot.ldsu-boot: $(u-boot-init) $(u-boot-main) u-boot.lds $(call if_changed,u-boot__)ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \ awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \$(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \ -c $(srctree)/common/system_map.c -o common/system_map.o $(call cmd,u-boot__) common/system_map.oendif# The actual objects are generated when descending,# make sure no implicit rule kicks in$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;# Handle descending into subdirectories listed in $(vmlinux-dirs)# Preset locale variables to speed up the build process. Limit locale# tweaks to this spot to avoid wrong language settings when running# make menuconfig etc.# Error messages still appears in the original languagePHONY += $(u-boot-dirs)$(u-boot-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@tools: prepare# The "tools" are needed early$(filter-out tools, $(u-boot-dirs)): tools# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC# is "yes"), so compile examples after U-Boot is compiled.examples: $(filter-out examples, $(u-boot-dirs))define filechk_uboot.release echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"endef# Store (new) UBOOTRELEASE string in include/config/uboot.releaseinclude/config/uboot.release: Makefile FORCE $(call filechk,uboot.release)# Things we need to do before we recursively start building the kernel# or the modules are listed in "prepare".# A multi level approach is used. prepareN is processed before prepareN-1.# archprepare is used in arch Makefiles and when processed asm symlink,# version.h and scripts_basic is processed / created.# Listed in dependency orderPHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3# prepare3 is used to check if we are building in a separate output directory,# and if so do:# 1) Check that make has not been executed in the kernel src $(srctree)prepare3: include/config/uboot.releaseifneq ($(KBUILD_SRC),) @$(kecho) ' Using $(srctree) as source for u-boot' $(Q)if [ -f $(srctree)/include/config.mk ]; then \ echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ echo >&2 " in the '$(srctree)' directory.";\ /bin/false; \ fi;endif# prepare2 creates a makefile if using a separate output directoryprepare2: prepare3 outputmakefileprepare1: prepare2 $(version_h) $(timestamp_h)ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)ifeq ($(CONFIG_SYS_GENERIC_BOARD),y) @echo >&2 " Your architecture does not support generic board." @echo >&2 " Please undefine CONFIG_SYS_GENERIC_BOARD in your board config file." @/bin/falseendifendififeq ($(wildcard $(LDSCRIPT)),) @echo >&2 " Could not find linker script." @/bin/falseendifarchprepare: prepare1 scripts_basicprepare0: archprepare FORCE $(Q)$(MAKE) $(build)=.# All the preparing..prepare: prepare0# Generate some files# ---------------------------------------------------------------------------define filechk_version.h (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \ echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \ echo \#define CC_VERSION_STRING \"$$($(CC) --version | head -n 1)\"; \echo \#define LD_VERSION_STRING \"$$($(LD) --version | head -n 1)\"; )endefdefine filechk_timestamp.h (LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \ LC_ALL=C date +'#define U_BOOT_TIME "%T"')endef$(version_h): include/config/uboot.release FORCE $(call filechk,version.h)$(timestamp_h): $(srctree)/Makefile FORCE $(call filechk,timestamp.h)## Auto-generate the autoconf.mk file (which is included by all makefiles)## This target actually generates 2 files; autoconf.mk and autoconf.mk.dep.# the dep file is only include in this top level makefile to determine when# to regenerate the autoconf.mk file.quiet_cmd_autoconf_dep = GEN $@ cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M $(c_flags) \ -MQ include/autoconf.mk $(srctree)/include/common.h > $@ || rm $@include/autoconf.mk.dep: include/config.h include/common.h $(call cmd,autoconf_dep)quiet_cmd_autoconf = GEN $@ cmd_autoconf = \ $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \ sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \ rm $@.tmpinclude/autoconf.mk: include/config.h $(call cmd,autoconf)# ---------------------------------------------------------------------------PHONY += depend depdepend dep: @echo '*** Warning: make $@ is unnecessary now.'# ---------------------------------------------------------------------------quiet_cmd_cpp_lds = LDS $@cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ -D__ASSEMBLY__ -x assembler-with-cpp -P -o $@ $<u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)spl/u-boot-spl.bin: spl/u-boot-spl @:spl/u-boot-spl: tools prepare $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl allspl/sunxi-spl.bin: spl/u-boot-spl @:tpl/u-boot-tpl.bin: tools prepare $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all CONFIG_TPL_BUILD=yTAG_SUBDIRS := $(u-boot-dirs) includeFIND := findFINDFLAGS := -Ltags ctags: ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ -name '*.[chS]' -print`etags: etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ -name '*.[chS]' -print`cscope: $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ cscope.files cscope -b -q -kSYSTEM_MAP = \ $(NM) $1 | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ LC_ALL=C sortSystem.map: u-boot @$(call SYSTEM_MAP,$<) > $@checkdtc: @if test $(call dtc-version) -lt 0104; then \ echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ false; \ fi########################################################################## ARM relocations should all be R_ARM_RELATIVE (32-bit) or# R_AARCH64_RELATIVE (64-bit).checkarmreloc: u-boot @RELOC="`$(CROSS_COMPILE)readelf -r -W $< | cut -d ' ' -f 4 | \ grep R_A | sort -u`"; \ if test "$$RELOC" != "R_ARM_RELATIVE" -a \ "$$RELOC" != "R_AARCH64_RELATIVE"; then \ echo "$< contains unexpected relocations: $$RELOC"; \ false; \ fienv: scripts_basic $(Q)$(MAKE) $(build)=tools/$@tools-only: scripts_basic $(version_h) $(timestamp_h) $(Q)$(MAKE) $(build)=toolstools-all: export HOST_TOOLS_ALL=ytools-all: env tools ;cross_tools: export CROSS_BUILD_TOOLS=ycross_tools: tools ;.PHONY : CHANGELOGCHANGELOG: git log --no-merges U-Boot-1_1_5.. | \ unexpand -a | sed -e 's/\s\s*$$//' > $@include/license.h: tools/bin2header COPYING cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h############################################################################# Cleaning is done on three levels.# make clean Delete most generated files# Leave enough to build external modules# make mrproper Delete the current configuration, and all generated files# make distclean Remove editor backup files, patch leftover files and the like# Directories & files removed with 'make clean'CLEAN_DIRS += $(MODVERDIR)CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \ include/autoconf.mk* include/spl-autoconf.mk \ include/tpl-autoconf.mk# Directories & files removed with 'make clobber'CLOBBER_DIRS += spl tplCLOBBER_FILES += u-boot* MLO* SPL System.map# Directories & files removed with 'make mrproper'MRPROPER_DIRS += include/config include/generated \ .tmp_objdiffMRPROPER_FILES += .config .config.old \ tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ include/config.h include/config.mk# clean - Delete most, but leave enough to build external modules#clean: rm-dirs := $(CLEAN_DIRS)clean: rm-files := $(CLEAN_FILES)clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f))clean-dirs := $(addprefix _clean_, $(clean-dirs) doc/DocBook)PHONY += $(clean-dirs) clean archclean$(clean-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)# TODO: Do not use *.cfgtmpclean: $(clean-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles) @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.symtypes' -o -name 'modules.order' \ -o -name modules.builtin -o -name '.tmp_*.o.*' \ -o -name '*.gcno' \) -type f -print | xargs rm -f# clobber#clobber: rm-dirs := $(CLOBBER_DIRS)clobber: rm-files := $(CLOBBER_FILES)PHONY += clobbertidy: @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -fclobber: clean tidy $(call cmd,rmdirs) $(call cmd,rmfiles)# mrproper - Delete all generated files, including .config#mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))mrproper: rm-files := $(wildcard $(MRPROPER_FILES))mrproper-dirs := $(addprefix _mrproper_,scripts)PHONY += $(mrproper-dirs) mrproper archmrproper$(mrproper-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)mrproper: clobber $(mrproper-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles) @rm -f arch/*/include/asm/arch# distclean#PHONY += distcleandistclean: mrproper @find $(srctree) $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' -o -name '*%' -o -name 'core' \ -o -name '*.pyc' \) \ -type f -print | xargs rm -fbackup: F=`basename $(srctree)` ; cd .. ; \ gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$Fhelp: @echo 'Cleaning targets:' @echo ' clean - Remove most generated files but keep the config and' @echo ' necessities for testing u-boot' @echo ' clobber - Remove most generated files but keep the config' @echo ' mrproper - Remove all generated files + config + various backup files' @echo ' distclean - mrproper + remove editor backup and patch files' @echo ''# uncomment after adding Kconfig feature# @echo 'Configuration targets:'# @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help# @echo '' @echo 'Other generic targets:' @echo ' all - Build all necessary images depending on configuration' @echo ' u-boot - Build the bare u-boot' @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[oisS] - Build specified target only' @echo ' dir/file.lst - Build specified mixed source/assembly target only' @echo ' (requires a recent binutils and recent build (System.map))' @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' @echo ' ubootrelease - Output the release version string' @echo ' ubootversion - Output the version stored in Makefile' @echo '' @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo '' @echo 'Documentation targets:' @$(MAKE) -f $(srctree)/doc/DocBook/Makefile dochelp @echo '' @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' @echo ' make V=2 [targets] 2 => give reason for rebuild of target' @echo ' make O=dir [targets] Locate all output files in "dir", including .config' @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'@echo ' make C=2 [targets] Force check of all c source with $$CHECK' @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' @echo ' 1: warnings which may be relevant and do not occur too often' @echo ' 2: warnings which occur quite often but may still be relevant' @echo ' 3: more obscure warnings, can most likely be ignored' @echo ' Multiple levels can be combined with W=12 or W=123' @echo '' @echo 'Execute "make" or "make all" to build all targets marked with [*] ' @echo 'For further info see the ./README file'# Documentation targets# ---------------------------------------------------------------------------%docs: scripts_basic FORCE $(Q)$(MAKE) $(build)=scripts build_docproc $(Q)$(MAKE) $(build)=doc/DocBook $@# Dummies...PHONY += prepare scriptsprepare: ;scripts: ;endif #ifeq ($(config-targets),1)endif #ifeq ($(mixed-targets),1)PHONY += checkstack ubootrelease ubootversioncheckstack: $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \ $(PERL) $(src)/scripts/checkstack.pl $(ARCH)ubootrelease: @echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"ubootversion: @echo $(UBOOTVERSION)# Single targets# ---------------------------------------------------------------------------# Single targets are compatible with:# - build with mixed source and output# - build with separate output dir 'make O=...'# - external modules## target-dir => where to store outputfile# build-dir => directory in kernel source tree to useifeq ($(KBUILD_EXTMOD),) build-dir = $(patsubst %/,%,$(dir $@)) target-dir = $(dir $@)else zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))endif%.s: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)%.i: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)%.o: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)%.lst: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)%.s: %.S prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)%.o: %.S prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)%.symtypes: %.c prepare scripts FORCE $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)# Modules/: prepare scripts FORCE $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)%/: prepare scripts FORCE $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir)%.ko: prepare scripts FORCE $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(build)=$(build-dir) $(@:.ko=.o) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost# FIXME Should go into a make.lib or something# ===========================================================================quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) cmd_rmdirs = rm -rf $(rm-dirs)quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) cmd_rmfiles = rm -f $(rm-files)# read all saved command linestargets := $(wildcard $(sort $(targets)))cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))ifneq ($(cmd_files),) $(cmd_files): ; # Do not try to update included dependency files include $(cmd_files)endif# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir# Usage:# $(Q)$(MAKE) $(clean)=dirclean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean objendif # skip-makefilePHONY += FORCEFORCE:# Declare the contents of the .PHONY variable as phony. We keep that# information in a variable so we can use it in if_changed and friends.# 声明.PHONY伪变量.PHONY: $(PHONY)
总结:注解这个文件还是很耗时间的,暂时先关注我们常见的,与我们需要的u-boot.bin的目标文件相关的。
阅读全文
0 0
- 【s5p4418嵌入式学习】u-boot学习之makefile注释07
- 【s5p4418嵌入式学习】u-boot学习之编译与Makefile结合分析08
- 嵌入式之U-Boot学习笔记
- 【s5p4418嵌入式学习】开篇01
- 嵌入式学习之u-boot学习笔记(1)
- 【s5p4418嵌入式学习】分步编译之uboot编译03
- 【s5p4418嵌入式学习】分步编译之kernel编译04
- 【s5p4418嵌入式学习】分步编译之module编译05
- 【s5p4418嵌入式学习】分步编译之安卓06
- u-boot 学习之 config 和 Makefile 分析
- u-boot学习笔记一(makefile)
- U-Boot中Makefile的学习
- 03-S3C2440u-boot学习之u-boot分析之Makefile结构分析
- u-boot 学习 /*嵌入式博客3_6*/
- 学习嵌入式Linux-JZ2440-U-Boot简介
- 嵌入式Linux学习-----u-boot移植
- u-boot 学习之综述
- u-boot 学习之常用命令
- Dict字典
- wireshark分析ARP协议
- 技术书籍推荐(C++方向)
- win10下安装ubuntu(微星GE62VR
- 超级简单的底部导航按钮
- 【s5p4418嵌入式学习】u-boot学习之makefile注释07
- Ubuntu使用vim编辑器时方向键乱码和退格键不能使用的问题
- 小型HTTP服务器
- sql语句实现查询
- LeetCode.62
- PAT 1012 排序
- java中System.exit()方法
- [LeetCode] 3. Longest Substring Without Repeating Characters
- Android Studio AIDL实现