uboot makefile注释
为什么要注释uboot的Makefile呢?这是一个玄学问题,首先,我本人对make的工作机制比较清楚,但是从来没自己写过Makefile,而且很多语法在配置编译条件的时候有点晕,所以想来注释一下这个uboot的makefile,毕竟无论怎样解释语法都没有例句来的直观不是么?同样的,更新全凭心情。
第一部分,是版本号等的定义,还有一些注意事项
# 版本号等
VERSION = 2019
PATCHLEVEL = 04
SUBLEVEL =
EXTRAVERSION =
NAME =
# 查看一些详细信息,请查阅./README
# 该文件中的注释只对开发者有用,对构建内核(u-boot)无益。
# 避免使用make的内嵌规则和变量,以提升性能并避免难以定位的Bug
# 指定make的引用路径
MAKEFLAGS += -rR --include-dir=$(CURDIR)
# 避免奇怪的字符集问题
# LC_ALL 所有的本地设置
# LC_COLLATE 本地字符比较方式
# LC_CTYPE 本地字符的字符集
# LC_MONETARY 本地字符货币格式化方式
# LC_NUMERIC 本地数字格式化方式
# LC_TIME 本地时间格式化方式
unexport LC_ALL
LC_COLLATE=C # C为默认值
LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC
# 避免与shell的环境变量发生冲突
unexport GREP_OPTIONS
# 我们使用的是递归构建,所以需要一些小规则。
#
# 首先,子makefile只能修改对应文件夹中的文件。如果依赖别的文件夹中的文件,
# 我们会调用对应文件夹下的make规则,这样就能保证对应文件夹下的文件是你所
# 需要的(这种情况还是比较少见的)。
#
# 对于那些具有全局影响的文件,我们都会在递归过程开始之前进行处理。这部分内容
# 被放在prepare规则下。
# 让输出优美一点
# ---------------------------------------------------------------------------
# 通常,在执行命令之前,都会行打印出来。通过使用$($(quiet)$(cmd))的方式
# 来设置输出格式,比如:
# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
# 在$(quiet)为空时,会打印整个命令
# 在$(quiet)为"quiet_"时,只会打印精简版本的提示信息
# 在$(quiet)为"silent_"时,则不会打印任何信息,因为
# $(slient_cmd_cc_o_c)不存在。
#
# 有一种简单的方式就是在命令之前加上$(Q),这在非verbose模式下精简输出很有用:
#
# $(Q)ln $@ :<
#
# 如果KBUILD_VERBOSE为0,那么该命令将会被隐藏
# 如果KBUILD_VERBOSE为1,那么该命令将会显示
#
# 如果比较关心警告信息,又不想输出信息像默认情况下那么冗长,就使用
# 'make V=1'来显示全部命令
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
else
quiet=quiet_
# "@" shell 语法,在命令运行时不回显
Q = @
endif
# 如果用户使用make -s(静默模式),则不打印命令
ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
quiet=silent_
endif
else # make-3.8x
ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
quiet=silent_
endif
endif
export quiet Q KBUILD_VERBOSE
第二部分,对输出目录的判定
# kbuild 支持将生成的文件保存在别的目录下,有两种方式(工作目录必须为源码目录):
# 1) O=
# 使用"make O=dir/to/store/output/files/"
# 2) 设置KBUILD_OUTPUT
# 设置环境变量KBUILD_OUTPUT来修改生成文件保存目录
# export KBUILD_OUTPUT=dir/to/store/output/files/
# make
#
# O= 比KBUILD_OUTPUT具有更高优先级
# KBUILD_SRC如果在指定输出目录时会被设置,第一次调用make时,会空
# KBUILD_SRC对于普通用户暂时用不上
ifeq ($(KBUILD_SRC),)
# 现在是在内核源码目录下调用make
# 是否指定输出目录?
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif
# 当未指定make规则时,这是我们的默认规则
PHONY := _all
_all:
# 屏蔽顶层Makefile的隐式规则,防止make在执行时试图为重建这个规则去查找隐含命令
$(CURDIR)/Makefile Makefile: ;
ifneq ($(KBUILD_OUTPUT),)
# 在输出目录下传递相关的变量并二次调用
# 确保输出目录存在
saved-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)"))
PHONY += $(MAKECMDGOALS) sub-make
# 去除MAKECMDGOALS中的重名规则
$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
@:
sub-make: FORCE
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
# 如果指定输出目录则本次Makefile解析停止,会在make时进行make。
skip-makefile := 1
endif # ifneq ($(KBUILD_OUTPUT),)
endif # ifeq ($(KBUILD_SRC),)
判断是否为最终Make,如果为最终make,则skip-makefile的值为空。只有最终Make才会进行真正的源码编译过程。
ifeq ($(skip-makefile),)
...
endif # skip-makefile
不打印"Entering directory …",但我们想要在进入输出目录时打印,这样IDE或编辑器可以明白文件名代表的路径。
MAKEFLAGS += --no-print-directory
指令编译过程中使用的源码检查器(默认为sparse)
make C=1为只检查需要重编译的文件
make C=2为检查所有的源文件,无论是否需要重编译
关于sparse暂时没有兴趣,可以百度一下,Documentation/sparse.text下有简要的介绍
ifeq ("$(origin C)", "command line")
KBUILD_CHECKSRC = $(C)
endif
ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
endif
使用make M=dir来指定需要构建的外部模块,同样支持旧的语法make … SUBDIRS=$PWD。
环境变量KBUILD_EXTMOD比SUBDIRS优先级高。
ifdef SUBDIRS
KBUILD_EXTMOD ?= $(SUBDIRS)
endif
ifeq ("$(origin M)", "command line")
KBUILD_EXTMOD := $(M)
endif
确定源码目录路径
# 如果是在构建外部模块,则不需要编译整个工程,_all就不需要依赖all。只需要依赖modules就可以。
PHONY += all
ifeq ($(KBUILD_EXTMOD),)
_all: all
else
_all: modules
endif
ifeq ($(KBUILD_SRC),)
# KBUILD_SRC为空,则当前目录就是源码目录
srctree := .
else
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
srctree := ..
else
srctree := $(KBUILD_SRC)
endif
endif
# 无论怎样,只要解析到这里,当前目录就是输出目录
objtree := .
src := $(srctree)
obj := $(objtree)
判断当前系统的CPU架构和操作系统
VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH
# 避免环境变量CDPATH的干扰
unexport CDPATH
#########################################################################
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/')
export HOSTARCH HOSTOS
#########################################################################
如果是本地编译,则不指定CROSS_COMPILE
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?=
endif
Kconfig的一些配置
# 默认的KCONFIG_CONFIG为.config
KCONFIG_CONFIG ?= .config
export KCONFIG_CONFIG
# Kconfig使用的shell
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
# 编译用的C编译器
HOSTCC = cc
# 编译用的C++编译器
HOSTCXX = c++
# C编译器参数
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
$(if $(CONFIG_TOOLS_DEBUG),-g)
# C++编译器参数
HOSTCXXFLAGS = -O2
因为移植到GCC 6,所以我们直接使用的GNU11标准。但是有些发行版只有旧版本的编译器,所以我们显式地声明需要使用gnu11
CSTD_FLAG := -std=gnu11
ifeq ($(HOSTOS),linux)
HOSTCFLAGS += $(CSTD_FLAG)
endif
cygwin兼容
ifeq ($(HOSTOS),cygwin)
HOSTCFLAGS += -ansi
endif
mac OS X/darwin 操作系统兼容
# 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 ;)
os_x_after = $(shell if [ $(DARWIN_MAJOR_VERSION) -ge $(1) -a \
$(DARWIN_MINOR_VERSION) -ge $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
# Snow Leopards build environment has no longer restrictions as described above
HOSTCC = $(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")
# since Lion (10.7) ASLR is on by default, but we use linker generated lists
# in some host tools which is a problem then ... so disable ASLR for these
# tools
HOSTLDFLAGS += $(call os_x_before, 10, 7, "", "-Xlinker -no_pie")
# macOS Mojave (10.14.X)
# Undefined symbols for architecture x86_64: "_PyArg_ParseTuple"
HOSTLDFLAGS += $(call os_x_after, 10, 14, "-lpython -dynamclib", "")
endif
判断是否构建内置内置模块或外部模块,通常只构建内置模块
KBUILD_MODULES :=
KBUILD_BUILTIN := 1
# 如果只有make modules,则不编译内置模块。
# 如果外部模块具有版本号,则需要检查内置模块的对象文件,
# 以确保校验码是匹配的。
ifeq ($(MAKECMDGOALS),modules)
KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
endif
# 只要输入参数中有modules,则在进行除定义的操作之外,编译外部模块
# 如果仅仅使用make或make all,也会编译外部模块。
# U-Boot 不需要模块
#ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
# KBUILD_MODULES := 1
#endif
#ifeq ($(MAKECMDGOALS),)
# KBUILD_MODULES := 1
#endif
export KBUILD_MODULES KBUILD_BUILTIN
export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
一些通用定义
scripts/Kbuild.include: ;
include scripts/Kbuild.include
make过程中用到的变量
# 汇编器
AS = $(CROSS_COMPILE)as
# 链接器,使用gnu ld
ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
LD = $(CROSS_COMPILE)ld.bfd
else
LD = $(CROSS_COMPILE)ld
endif
# C编译器
CC = $(CROSS_COMPILE)gcc
# C++编译器
CPP = $(CC) -E
# archieve生成器
AR = $(CROSS_COMPILE)ar
# 符号表查看器
NM = $(CROSS_COMPILE)nm
# 不知道是什么
LDR = $(CROSS_COMPILE)ldr
# 从特定文件中剥掉一些符号信息和调试信息,使文件变小。
STRIP = $(CROSS_COMPILE)strip
# 将目标文件的一部分或者全部内容拷贝到另外一个目标文件中,或者实现目标文件的格式转换。
OBJCOPY = $(CROSS_COMPILE)objcopy
# 反汇编目标文件或者可执行文件的命令,它以一种可阅读的格式让你更多地了解二进制文件可能带有的附加信息。
OBJDUMP = $(CROSS_COMPILE)objdump
# 语法分析工具和脚本语言
LEX = flex
YACC = bison
AWK = awk
PERL = perl
PYTHON ?= python
PYTHON2 = python2
PYTHON3 = python3
# 设备树编译器
DTC ?= $(objtree)/scripts/dtc/dtc
CHECK = sparse
# 语法检查参数
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
-Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
# C++编译器参数
KBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__
# C编译器参数
KBUILD_CFLAGS := -Wall -Wstrict-prototypes \
-Wno-format-security \
-fno-builtin -ffreestanding $(CSTD_FLAG)
KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing
KBUILD_AFLAGS := -D__ASSEMBLY__
# 编译生成的程序中不使用绝对地址
KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
# UBOOT版本号
UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
export MAKE LEX YACC AWK PERL PYTHON PYTHON2 PYTHON3
export HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS DTC DTC_FLAGS
export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS
export 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 ... statements
export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
-name CVS -o -name .pc -o -name .hg -o -name .git \) \
-prune -o
export 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
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.
outputmakefile:
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.h
timestamp_h := include/generated/timestamp_autogenerated.h
defaultenv_h := include/generated/defaultenv_autogenerated.h
no-dot-config-targets := clean clobber mrproper distclean \
help %docs check% coccicheck \
ubootversion backup tests check qcheck
config-targets := 0
mixed-targets := 0
dot-config := 1
ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
dot-config := 0
endif
endif
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(filter config %config,$(MAKECMDGOALS)),)
config-targets := 1
ifneq ($(words $(MAKECMDGOALS)),1)
mixed-targets := 1
endif
endif
endif
ifeq ($(mixed-targets),1)
# ===========================================================================
# We're called with mixed targets (*config and build targets).
# Handle them one by one.
PHONY += $(MAKECMDGOALS) __build_one_by_one
$(filter-out __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; \
done
else
ifeq ($(config-targets),1)
# ===========================================================================
# *config targets only - make sure prerequisites are updated, and descend
# in scripts/kconfig to make the *config target
KBUILD_DEFCONFIG := sandbox_defconfig
export KBUILD_DEFCONFIG KBUILD_KCONFIG
config: scripts_basic outputmakefile FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
%config: scripts_basic outputmakefile FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
else
# ===========================================================================
# Build targets only - this includes vmlinux, arch specific targets, clean
# targets and others. In general all targets except *config targets.
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
# in parallel
PHONY += scripts
scripts: scripts_basic include/config/auto.conf
$(Q)$(MAKE) $(build)=$(@)
ifeq ($(dot-config),1)
# Read in config
-include include/config/auto.conf
# Read in dependencies to all Kconfig* files, make sure to run
# oldconfig if changes are detected.
-include include/config/auto.conf.cmd
# To avoid any implicit rule to kick in, define an empty command
$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
# If .config is newer than include/config/auto.conf, someone tinkered
# with it and forgot to run make oldconfig.
# if auto.conf.cmd is missing then we are probably in a cleaned tree so
# we execute the config step to be sure to catch updated Kconfig files
include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
@# If the following part fails, include/config/auto.conf should be
@# deleted so "make silentoldconfig" will be re-run on the next build.
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \
{ rm -f include/config/auto.conf; false; }
@# include/config.h has been updated after "make silentoldconfig".
@# We need to touch include/config/auto.conf so it gets newer
@# than include/config.h.
@# Otherwise, 'make silentoldconfig' would be invoked twice.
$(Q)touch include/config/auto.conf
u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(@)
-include include/autoconf.mk
-include include/autoconf.mk.dep
# We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf
# is up-to-date. When we switch to a different board configuration, old CONFIG
# macros are still remaining in include/config/auto.conf. Without the following
# gimmick, wrong config.mk would be included leading nasty warnings/errors.
ifneq ($(wildcard $(KCONFIG_CONFIG)),)
ifneq ($(wildcard include/config/auto.conf),)
autoconf_is_old := $(shell find . -path ./$(KCONFIG_CONFIG) -newer \
include/config/auto.conf)
ifeq ($(autoconf_is_old),)
include config.mk
include arch/$(ARCH)/Makefile
endif
endif
endif
# These are set by the arch-specific config.mk. Make sure they are exported
# so they can be used when building an EFI application.
export EFI_LDS # Filename of EFI link script in arch/$(ARCH)/lib
export EFI_CRT0 # Filename of EFI CRT0 in arch/$(ARCH)/lib
export EFI_RELOC # Filename of EFU relocation code in arch/$(ARCH)/lib
export CFLAGS_EFI # Compiler flags to add when building EFI app
export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app
export EFI_TARGET # binutils target if EFI is natively supported
# 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.
ifndef LDSCRIPT
#LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug
ifdef CONFIG_SYS_LDSCRIPT
# need to strip off double quotes
LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%)
endif
endif
# If there is no specified link script, we look in a number of places for it
ifndef LDSCRIPT
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
endif
endif
else
# Dummy target needed, because used as prerequisite
include/config/auto.conf: ;
endif # $(dot-config)
#
# Xtensa linker script cannot be preprocessed with -ansi because of
# preprocessor operations on strings that don't make C identifiers.
#
ifeq ($(CONFIG_XTENSA),)
LDPPFLAGS += -ansi
endif
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += -Os
else
KBUILD_CFLAGS += -O2
endif
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
# change __FILE__ to the relative path from the srctree
KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
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 supported
# ARC tools based on GCC 7.1 has an issue with stack usage
# with naked functions, see commit message for more details
ifndef CONFIG_ARC
ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y)
KBUILD_CFLAGS += -fstack-usage
endif
endif
KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral)
ifeq ($(cc-name),clang)
KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier)
KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
endif
# turn jbsr into jsr for m68k
ifeq ($(ARCH),m68k)
ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
KBUILD_AFLAGS += -Wa,-gstabs,-S
endif
endif
# Prohibit date/time macros, which would make the build non-deterministic
KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
include scripts/Makefile.extrawarn
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
KBUILD_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
UBOOTINCLUDE := \
-Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
$(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
$(if $(CONFIG_HAS_THUMB2),, \
-I$(srctree)/arch/$(ARCH)/thumb1/include),) \
-I$(srctree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
# FIX ME
cpp_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)
HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
libs-y += lib/
libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
libs-$(CONFIG_OF_EMBED) += dts/
libs-y += fs/
libs-y += net/
libs-y += disk/
libs-y += drivers/
libs-y += drivers/dma/
libs-y += drivers/gpio/
libs-y += drivers/i2c/
libs-y += drivers/mtd/
libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/raw/
libs-y += drivers/mtd/onenand/
libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
libs-y += drivers/mtd/spi/
libs-y += drivers/net/
libs-y += drivers/net/phy/
libs-y += drivers/power/ \
drivers/power/domain/ \
drivers/power/fuel_gauge/ \
drivers/power/mfd/ \
drivers/power/pmic/ \
drivers/power/battery/ \
drivers/power/regulator/
libs-y += drivers/spi/
libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl/
libs-$(CONFIG_ALTERA_SDRAM) += drivers/ddr/altera/
libs-y += drivers/serial/
libs-y += drivers/usb/dwc3/
libs-y += drivers/usb/common/
libs-y += drivers/usb/emul/
libs-y += drivers/usb/eth/
libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/
libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/udc/
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 += cmd/
libs-y += common/
libs-y += env/
libs-$(CONFIG_API) += api/
libs-$(CONFIG_HAS_POST) += post/
libs-$(CONFIG_UNIT_TEST) += test/ test/dm/
libs-$(CONFIG_UT_ENV) += test/env/
libs-$(CONFIG_UT_OVERLAY) += test/overlay/
libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
libs-y := $(sort $(libs-y))
u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
u-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 lib
ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
else
PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
endif
PLATFORM_LIBS += $(PLATFORM_LIBGCC)
ifdef CONFIG_CC_COVERAGE
KBUILD_CFLAGS += --coverage
PLATFORM_LIBGCC += -lgcov
endif
export PLATFORM_LIBS
export PLATFORM_LIBGCC
# Special flags for CPP when processing the linker script.
# Pass the version down so we can handle backwards compatibility
# on the fly.
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; \
fi
else
BOARD_SIZE_CHECK =
endif
# Statically apply RELA-style relocations (currently arm64 only)
# 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).
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 $$end
else
DO_STATIC_RELA =
endif
# ALL-yw使用添加的方式,这样不同架构下的config.mk文件可以添加自定义的项目
ALL-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check
ALL-$(CONFIG_ONENAND_U_BOOT) += u-boot-onenand.bin
# 使用Secondary Program Loader, FSL(Freescale?), PBL(Primary Boot Loader)
ifeq ($(CONFIG_SPL_FSL_PBL),y)
# 如果内存启动
ALL-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin
else
ifneq ($(CONFIG_SECURE_BOOT), y)
# 对于Secure Boot,启动镜像需要签名,并且需要包括头文件。所以显式构建
ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
endif
endif
ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
# MX6架构下使用Secure Boot,这两种架构需要使用IVT(Image Vector Table,该表中存储了镜像中不同内容的位置)
ifeq ($(CONFIG_MX6)$(CONFIG_SECURE_BOOT), yy)
ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
else
# MX7架构下使用Secure Boot
ifeq ($(CONFIG_MX7)$(CONFIG_SECURE_BOOT), yy)
ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img
else
ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
endif
e
ndif
# 可能是不同于boot-loader和SBL的又一个阶段
ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
# 将镜像与设备树分离
ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb
# 如果使用SPL框架,则将设备树和镜像合并
ifeq ($(CONFIG_SPL_FRAMEWORK),y)
ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
endif
ALL-$(CONFIG_OF_HOSTFILE) += u-boot.dtb
ifneq ($(CONFIG_SPL_TARGET),)
ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
endif
ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf
ALL-$(CONFIG_EFI_APP) += u-boot-app.efi
ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
ifneq ($(BUILD_ROM)$(CONFIG_BUILD_ROM),)
ALL-$(CONFIG_X86_RESET_VECTOR) += u-boot.rom
endif
# Build a combined spl + u-boot image for sunxi
ifeq ($(CONFIG_ARCH_SUNXI)$(CONFIG_SPL),yy)
ALL-y += u-boot-sunxi-with-spl.bin
endif
# enable combined SPL/u-boot/dtb rules for tegra
ifeq ($(CONFIG_TEGRA)$(CONFIG_SPL),yy)
ALL-y += u-boot-tegra.bin u-boot-nodtb-tegra.bin
ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb-tegra.bin
endif
ALL-$(CONFIG_ARCH_MEDIATEK) += u-boot-mtk.bin
# Add optional build target if defined in board/cpu/soc headers
ifneq ($(CONFIG_BUILD_TARGET),)
ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
endif
ifneq ($(CONFIG_SYS_INIT_SP_BSS_OFFSET),)
ALL-y += init_sp_bss_offset_check
endif
ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
ALL-y += u-boot-with-dtb.bin
endif
LDFLAGS_u-boot += $(LDFLAGS_FINAL)
Avoid ‘Not enough room for program headers’ error on binutils 2.28 onwards.
LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker)
ifeq (
(
C
O
N
F
I
G
A
R
C
)
(CONFIG_ARC)
(CONFIGARC)(CONFIG_NIOS2)
(
C
O
N
F
I
G
X
86
)
(CONFIG_X86)
(CONFIGX86)(CONFIG_XTENSA),)
LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
endif
Normally we fill empty space with 0xff
quiet_cmd_objcopy = OBJCOPY $@
cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS)
KaTeX parse error: Expected group after '_' at position 14: (OBJCOPYFLAGS_̲(@F)) $< $@
Provide a version which does not do this, for use by EFI
quiet_cmd_zobjcopy = OBJCOPY $@
cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) KaTeX parse error: Expected group after '_' at position 14: (OBJCOPYFLAGS_̲(@F)) $< $@
quiet_cmd_efipayload = OBJCOPY $@
cmd_efipayload = $(OBJCOPY) -I binary -O $(EFIPAYLOAD_BFDTARGET) -B $(EFIPAYLOAD_BFDARCH) $< $@
MKIMAGEOUTPUT ?= /dev/null
quiet_cmd_mkimage = MKIMAGE $@
cmd_mkimage = $(objtree)/tools/mkimage KaTeX parse error: Expected group after '_' at position 14: (MKIMAGEFLAGS_̲(@F)) -d $< KaTeX parse error: Expected 'EOF', got '\ ' at position 3: @ \̲ ̲ >(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
quiet_cmd_mkfitimage = MKIMAGE $@
cmd_mkfitimage = $(objtree)/tools/mkimage KaTeX parse error: Expected group after '_' at position 14: (MKIMAGEFLAGS_̲(@F)) -f $(U_BOOT_ITS) -p $(CONFIG_FIT_EXTERNAL_OFFSET) KaTeX parse error: Expected 'EOF', got '\ ' at position 2: @\̲ ̲ >(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
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 $@
cfg: u-boot.cfg
quiet_cmd_cfgcheck = CFGCHK $2
cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2
$(srctree)/scripts/config_whitelist.txt $(srctree)
这就是整个编译过程,依赖于ALL-y,也就是在配置过程中用户规定需要编译的部分。
```makefile
all: $(ALL-y)
ifeq ($(CONFIG_DM_I2C_COMPAT)$(CONFIG_SANDBOX),y)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board uses CONFIG_DM_I2C_COMPAT. Please remove"
@echo >&2 "(possibly in a subsequent patch in your series)"
@echo >&2 "before sending patches to the mailing list."
@echo >&2 "===================================================="
endif
ifeq ($(CONFIG_MMC),y)
ifneq ($(CONFIG_DM_MMC)$(CONFIG_OF_CONTROL)$(CONFIG_BLK),yyy)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_MMC. Please update"
@echo >&2 "the board to use CONFIG_DM_MMC before the v2019.04 release."
@echo >&2 "Failure to update by the deadline may result in board removal."
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
ifeq ($(CONFIG_USB),y)
ifneq ($(CONFIG_DM_USB)$(CONFIG_OF_CONTROL)$(CONFIG_BLK),yyy)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_USB. Please update"
@echo >&2 "the board to use CONFIG_DM_USB before the v2019.07 release."
@echo >&2 "Failure to update by the deadline may result in board removal."
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
ifeq ($(CONFIG_LIBATA)$(CONFIG_MVSATA_IDE),y)
ifneq ($(CONFIG_DM_SCSI),y)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_SCSI. Please update"
@echo >&2 "the storage controller to use CONFIG_DM_SCSI before the v2019.07 release."
@echo >&2 "Failure to update by the deadline may result in board removal."
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
ifeq ($(CONFIG_PCI),y)
ifneq ($(CONFIG_DM_PCI),y)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_PCI Please update"
@echo >&2 "the board to use CONFIG_DM_PCI before the v2019.07 release."
@echo >&2 "Failure to update by the deadline may result in board removal."
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
ifneq ($(CONFIG_LCD)$(CONFIG_VIDEO),)
ifneq ($(CONFIG_DM_VIDEO),y)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_VIDEO Please update"
@echo >&2 "the board to use CONFIG_DM_VIDEO before the v2019.07 release."
@echo >&2 "Failure to update by the deadline may result in board removal."
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
ifeq ($(CONFIG_OF_EMBED),y)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "CONFIG_OF_EMBED is enabled. This option should only"
@echo >&2 "be used for debugging purposes. Please use"
@echo >&2 "CONFIG_OF_SEPARATE for boards in mainline."
@echo >&2 "See doc/README.fdt-control for more info."
@echo >&2 "===================================================="
endif
ifeq ($(CONFIG_SPI),y)
ifneq ($(CONFIG_DM_SPI)$(CONFIG_OF_CONTROL),yy)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_SPI. Please update"
@echo >&2 "the board before v2019.04 for no dm conversion"
@echo >&2 "and v2019.07 for partially dm converted drivers."
@echo >&2 "Failure to update can lead to driver/board removal"
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
ifeq ($(CONFIG_SPI_FLASH),y)
ifneq ($(CONFIG_DM_SPI_FLASH)$(CONFIG_OF_CONTROL),yy)
@echo >&2 "===================== WARNING ======================"
@echo >&2 "This board does not use CONFIG_DM_SPI_FLASH. Please update"
@echo >&2 "the board to use CONFIG_SPI_FLASH before the v2019.07 release."
@echo >&2 "Failure to update by the deadline may result in board removal."
@echo >&2 "See doc/driver-model/MIGRATION.txt for more info."
@echo >&2 "===================================================="
endif
endif
@# Check that this build does not use CONFIG options that we do not
@# know about unless they are in Kconfig. All the existing CONFIG
@# options are whitelisted, so new ones should not be added.
$(call cmd,cfgcheck,u-boot.cfg)
PHONY += dtbs
dtbs: dts/dt.dtb
@:
dts/dt.dtb: u-boot
(
Q
)
(Q)
(Q)(MAKE) $(build)=dts dtbs
quiet_cmd_copy = COPY $@
cmd_copy = cp $< $@
ifeq ($(CONFIG_MULTI_DTB_FIT),y)
fit-dtb.blob: dts/dt.dtb FORCE
$(call if_changed,mkimage)
MKIMAGEFLAGS_fit-dtb.blob = -f auto -A $(ARCH) -T firmware -C none -O u-boot
-a 0 -e 0 -E
(
p
a
t
s
u
b
s
t
(patsubst %,-b arch/
(patsubst(ARCH)/dts/%.dtb,
(
s
u
b
s
t
"
,
,
(subst ",,
(subst",,(CONFIG_OF_LIST))) -d /dev/null
u-boot-fit-dtb.bin: u-boot-nodtb.bin fit-dtb.blob
$(call if_changed,cat)
u-boot.bin: u-boot-fit-dtb.bin FORCE
(
c
a
l
l
i
f
c
h
a
n
g
e
d
,
c
o
p
y
)
e
l
s
e
i
f
e
q
(
(call if_changed,copy) else ifeq (
(callifchanged,copy)elseifeq((CONFIG_OF_SEPARATE),y)
u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
$(call if_changed,cat)
u-boot.bin: u-boot-dtb.bin FORCE
$(call if_changed,copy)
else
u-boot.bin: u-boot-nodtb.bin FORCE
$(call if_changed,copy)
endif
%.imx: %.bin
(
Q
)
(Q)
(Q)(MAKE) $(build)=arch/arm/mach-imx $@
%.vyb: %.imx
(
Q
)
(Q)
(Q)(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $@
quiet_cmd_copy = COPY $@
cmd_copy = cp $< $@
u-boot.dtb: dts/dt.dtb
$(call cmd,copy)
OBJCOPYFLAGS_u-boot.hex := -O ihex
OBJCOPYFLAGS_u-boot.srec := -O srec
u-boot.hex u-boot.srec: u-boot FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_u-boot-elf.srec := $(OBJCOPYFLAGS_u-boot.srec)
u-boot-elf.srec: u-boot.elf FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_u-boot-spl.srec = $(OBJCOPYFLAGS_u-boot.srec)
spl/u-boot-spl.srec: spl/u-boot-spl FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary
$(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec)
$(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR),-R .bootpg -R .resetvec)
OBJCOPYFLAGS_u-boot-spl.hex = $(OBJCOPYFLAGS_u-boot.hex)
spl/u-boot-spl.hex: spl/u-boot-spl FORCE
$(call if_changed,objcopy)
binary_size_check: u-boot-nodtb.bin FORCE
@file_size=$(shell wc -c u-boot-nodtb.bin | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲') ; \ map_siz…1} /_image_binary_end/ {end = KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲ END {if (start…map_size" ]; then
if test
m
a
p
s
i
z
e
−
n
e
map_size -ne
mapsize−nefile_size; then
echo “u-boot.map shows a binary size of KaTeX parse error: Expected 'EOF', got '&' at position 12: map_size" >&̲2 ; \ echo "…file_size” >&2 ;
exit 1;
fi
fi
ifneq (
(
C
O
N
F
I
G
S
Y
S
I
N
I
T
S
P
B
S
S
O
F
F
S
E
T
)
,
)
i
f
n
e
q
(
(CONFIG_SYS_INIT_SP_BSS_OFFSET),) ifneq (
(CONFIGSYSINITSPBSSOFFSET),)ifneq((CONFIG_SYS_MALLOC_F_LEN),)
subtract_sys_malloc_f_len = space=
(
(
((
(({space} - $(CONFIG_SYS_MALLOC_F_LEN)))
else
subtract_sys_malloc_f_len = true
endif
The 1/4 margin below is somewhat arbitrary. The likely initial SP usage is
so low that the DTB could probably use 90%+ of the available space, for
current values of CONFIG_SYS_INIT_SP_BSS_OFFSET at least. However, let’s be
safe for now and tweak this later if space becomes tight.
A rejected alternative would be to check that some absolute minimum stack
space was available. However, since CONFIG_SYS_INIT_SP_BSS_OFFSET is
deliberately build-specific, to take account of build-to-build stack usage
differences due to different feature sets, there is no common absolute value
to check against.
init_sp_bss_offset_check: u-boot.dtb FORCE
@dtb_size=$(shell wc -c u-boot.dtb | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 1}̲') ; \ space=$…((KaTeX parse error: Expected 'EOF', got '\ ' at position 17: …space} / 4)) ; \̲ ̲ if [ {dtb_size} -gt $${quarter_space} ]; then
echo "u-boot.dtb is larger than 1 quarter of " >&2 ;
echo “(CONFIG_SYS_INIT_SP_BSS_OFFSET - CONFIG_SYS_MALLOC_F_LEN)” >&2 ;
exit 1 ;
fi
endif
u-boot-nodtb.bin: u-boot FORCE
$(call if_changed,objcopy)
(
c
a
l
l
D
O
S
T
A
T
I
C
R
E
L
A
,
(call DO_STATIC_RELA,
(callDOSTATICRELA,<,
@
,
@,
@,(CONFIG_SYS_TEXT_BASE))
$(BOARD_SIZE_CHECK)
u-boot.ldr: u-boot
$(CREATE_LDR_ENV)
$(LDR) -T $(CONFIG_CPU) -c $@ $< $(LDR_FLAGS)
$(BOARD_SIZE_CHECK)
binman
---------------------------------------------------------------------------
Use ‘make BINMAN_DEBUG=1’ to enable debugging
quiet_cmd_binman = BINMAN $@
cmd_binman = $(srctree)/tools/binman/binman -u -d u-boot.dtb -O . -m
-I . -I $(srctree) -I
(
s
r
c
t
r
e
e
)
/
b
o
a
r
d
/
(srctree)/board/
(srctree)/board/(BOARDDIR)
$(if $(BINMAN_DEBUG),-D) KaTeX parse error: Expected group after '_' at position 8: (BINMAN_̲(@F)) $<
OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
u-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_START
CONFIG_SYS_UBOOT_START := 0
endif
Boards with more complex image requirments can provide an .its source file
or a generator script
ifneq ($(CONFIG_SPL_FIT_SOURCE),"")
U_BOOT_ITS =
(
s
u
b
s
t
"
,
,
(subst ",,
(subst",,(CONFIG_SPL_FIT_SOURCE))
else
ifneq (
(
C
O
N
F
I
G
S
P
L
F
I
T
G
E
N
E
R
A
T
O
R
)
,
"
"
)
U
B
O
O
T
I
T
S
:
=
u
−
b
o
o
t
.
i
t
s
i
f
e
q
(
(CONFIG_SPL_FIT_GENERATOR),"") U_BOOT_ITS := u-boot.its ifeq (
(CONFIGSPLFITGENERATOR),"")UBOOTITS:=u−boot.itsifeq((CONFIG_SPL_FIT_GENERATOR),“arch/arm/mach-imx/mkimage_fit_atf.sh”)
U_BOOT_ITS_DEPS += u-boot-nodtb.bin
endif
ifeq ($(CONFIG_SPL_FIT_GENERATOR),“arch/arm/mach-rockchip/make_fit_atf.py”)
U_BOOT_ITS_DEPS += u-boot
endif
$(U_BOOT_ITS): $(U_BOOT_ITS_DEPS) FORCE
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SPL_FIT_GENERATOR)
(
p
a
t
s
u
b
s
t
(patsubst %,arch/
(patsubst(ARCH)/dts/%.dtb,
(
s
u
b
s
t
"
,
,
(subst ",,
(subst",,(CONFIG_OF_LIST))) > $@
endif
endif
ifdef CONFIG_SPL_LOAD_FIT
MKIMAGEFLAGS_u-boot.img = -f auto -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” -E
(
p
a
t
s
u
b
s
t
(patsubst %,-b arch/
(patsubst(ARCH)/dts/%.dtb,
(
s
u
b
s
t
"
,
,
(subst ",,
(subst",,(CONFIG_OF_LIST)))
else
MKIMAGEFLAGS_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-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O u-boot
-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START)
-n “U-Boot $(UBOOTRELEASE) for $(BOARD) board”
u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log
CLEAN_FILES += u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log
endif
MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
MKIMAGEFLAGS_u-boot.kwb = -n
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SYS_KWD_CONFIG:"%"=%)
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
MKIMAGEFLAGS_u-boot-spl.kwb = -n
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SYS_KWD_CONFIG:"%"=%)
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
$(if $(KEYDIR),-k $(KEYDIR))
MKIMAGEFLAGS_u-boot.pbl = -n
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SYS_FSL_PBL_RCW:"%"=%)
-R
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img:
$(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin dts/dt.dtb,u-boot.bin) FORCE
$(call if_changed,mkimage)
$(BOARD_SIZE_CHECK)
ifeq ($(CONFIG_SPL_LOAD_FIT_FULL),y)
MKIMAGEFLAGS_u-boot.itb =
else
MKIMAGEFLAGS_u-boot.itb = -E
endif
u-boot.itb: u-boot-nodtb.bin dts/dt.dtb $(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
$(BOARD_SIZE_CHECK)
u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
u-boot.sha1: u-boot.bin
tools/ubsha1 u-boot.bin
u-boot.dis: u-boot
$(OBJDUMP) -d $< > $@
ifneq ($(CONFIG_SPL_PAYLOAD),)
SPL_PAYLOAD := $(CONFIG_SPL_PAYLOAD:"%"=%)
else
SPL_PAYLOAD := u-boot.bin
endif
OBJCOPYFLAGS_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)
ifeq (
(
C
O
N
F
I
G
A
R
C
H
L
P
C
32
X
X
)
(CONFIG_ARCH_LPC32XX)
(CONFIGARCHLPC32XX)(CONFIG_SPL),yy)
MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE)
lpc32xx-spl.img: spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
OBJCOPYFLAGS_lpc32xx-boot-0.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
lpc32xx-boot-0.bin: lpc32xx-spl.img FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_lpc32xx-boot-1.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
lpc32xx-boot-1.bin: lpc32xx-spl.img FORCE
$(call if_changed,objcopy)
lpc32xx-full.bin: lpc32xx-boot-0.bin lpc32xx-boot-1.bin u-boot.img FORCE
$(call if_changed,cat)
CLEAN_FILES += lpc32xx-*
endif
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
)
(Q)
(Q)(MAKE) $(build)=arch/arm/mach-imx $@
ifeq (
(
C
O
N
F
I
G
A
R
C
H
I
M
X
8
M
)
(CONFIG_ARCH_IMX8M)
(CONFIGARCHIMX8M)(CONFIG_ARCH_IMX8), y)
flash.bin: spl/u-boot-spl.bin u-boot.itb FORCE
(
Q
)
(Q)
(Q)(MAKE) $(build)=arch/arm/mach-imx $@
endif
u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE
(
Q
)
(Q)
(Q)(MAKE) $(build)=arch/arm/mach-imx $@
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),
(
s
r
c
t
r
e
e
)
/
(srctree)/
(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
)
(Q)
(Q)(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb
u-boot.sb: u-boot.bin spl/u-boot-spl.bin
(
Q
)
(Q)
(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.spr
MKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none
-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER
spl/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=0xff
u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE
$(call if_changed,pad_cat)
ifneq ($(CONFIG_ARCH_SOCFPGA),)
quiet_cmd_socboot = SOCBOOT $@
cmd_socboot = cat spl/u-boot-spl.sfp spl/u-boot-spl.sfp
spl/u-boot-spl.sfp spl/u-boot-spl.sfp
u-boot.img > $@ || rm -f $@
u-boot-with-spl.sfp: spl/u-boot-spl.sfp u-boot.img FORCE
$(call if_changed,socboot)
endif
ifeq (
(
C
O
N
F
I
G
M
P
C
85
x
x
)
(CONFIG_MPC85xx)
(CONFIGMPC85xx)(CONFIG_OF_SEPARATE),yy)
u-boot-with-dtb.bin: u-boot.bin u-boot.dtb
$(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR), u-boot-br.bin) FORCE
$(call if_changed,binman)
ifeq ($(CONFIG_MPC85XX_HAVE_RESET_VECTOR),y)
OBJCOPYFLAGS_u-boot-br.bin := -O binary -j .bootpg -j .resetvec
u-boot-br.bin: u-boot FORCE
$(call if_changed,objcopy)
endif
endif
x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in
the middle. This is handled by binman based on an image description in the
board’s device tree.
ifneq ($(CONFIG_X86_RESET_VECTOR),)
rom: u-boot.rom FORCE
refcode.bin:
(
s
r
c
t
r
e
e
)
/
b
o
a
r
d
/
(srctree)/board/
(srctree)/board/(BOARDDIR)/refcode.bin FORCE
$(call if_changed,copy)
quiet_cmd_ldr = LD $@
cmd_ldr = $(LD) KaTeX parse error: Expected group after '_' at position 9: (LDFLAGS_̲(@F))
(
f
i
l
t
e
r
−
o
u
t
F
O
R
C
E
,
(filter-out FORCE,
(filter−outFORCE,^) -o $@
u-boot.rom: u-boot-x86-16bit.bin u-boot.bin
$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin)
$(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE
$(call if_changed,binman)
OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
u-boot-x86-16bit.bin: u-boot FORCE
$(call if_changed,objcopy)
endif
ifneq (
(
C
O
N
F
I
G
A
R
C
H
S
U
N
X
I
)
,
)
i
f
e
q
(
(CONFIG_ARCH_SUNXI),) ifeq (
(CONFIGARCHSUNXI),)ifeq((CONFIG_ARM64),)
u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
$(call if_changed,binman)
else
u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.itb FORCE
$(call if_changed,cat)
endif
endif
ifneq ( ( C O N F I G T E G R A ) , ) i f n e q ( (CONFIG_TEGRA),) ifneq ( (CONFIGTEGRA),)ifneq((CONFIG_BINMAN),)
Makes u-boot-dtb-tegra.bin u-boot-tegra.bin u-boot-nodtb-tegra.bin
%-dtb-tegra.bin %-tegra.bin %-nodtb-tegra.bin:
spl/%-spl %.bin FORCE
(
c
a
l
l
i
f
c
h
a
n
g
e
d
,
b
i
n
m
a
n
)
e
l
s
e
O
B
J
C
O
P
Y
F
L
A
G
S
u
−
b
o
o
t
−
n
o
d
t
b
−
t
e
g
r
a
.
b
i
n
=
−
O
b
i
n
a
r
y
−
−
p
a
d
−
t
o
=
(call if_changed,binman) else OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=
(callifchanged,binman)elseOBJCOPYFLAGSu−boot−nodtb−tegra.bin=−Obinary−−pad−to=(CONFIG_SYS_TEXT_BASE)
u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot-nodtb.bin FORCE
$(call if_changed,pad_cat)
OBJCOPYFLAGS_u-boot-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
u-boot-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
$(call if_changed,pad_cat)
u-boot-dtb-tegra.bin: u-boot-tegra.bin FORCE
$(call if_changed,copy)
endif # binman
endif
OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI)
u-boot-app.efi: u-boot FORCE
$(call if_changed,zobjcopy)
u-boot.bin.o: u-boot.bin FORCE
$(call if_changed,efipayload)
u-boot-payload.lds: $(LDSCRIPT_EFI) FORCE
$(call if_changed_dep,cpp_lds)
Rule to link the EFI payload which contains a stub and a U-Boot binary
quiet_cmd_u-boot_payload ?= LD $@
cmd_u-boot_payload ?= $(LD) $(LDFLAGS_EFI_PAYLOAD) -o $@
-T u-boot-payload.lds arch/x86/cpu/call32.o
lib/efi/efi.o lib/efi/efi_stub.o u-boot.bin.o
(
a
d
d
p
r
e
f
i
x
a
r
c
h
/
(addprefix arch/
(addprefixarch/(ARCH)/lib/,$(EFISTUB))
u-boot-payload: u-boot.bin.o u-boot-payload.lds FORCE
$(call if_changed,u-boot_payload)
OBJCOPYFLAGS_u-boot-payload.efi := $(OBJCOPYFLAGS_EFI)
u-boot-payload.efi: u-boot-payload FORCE
$(call if_changed,zobjcopy)
u-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
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SYS_FSL_PBL_RCW:"%"=%)
-R
(
s
r
c
t
r
e
e
)
/
(srctree)/
(srctree)/(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
-A $(ARCH) -a $(CONFIG_SPL_TEXT_BASE)
spl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
ifeq (
(
A
R
C
H
)
,
a
r
m
)
U
B
O
O
T
B
I
N
L
O
A
D
:
=
u
−
b
o
o
t
.
i
m
g
e
l
s
e
i
f
e
q
(
(ARCH),arm) UBOOT_BINLOAD := u-boot.img else ifeq (
(ARCH),arm)UBOOTBINLOAD:=u−boot.imgelseifeq((CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy)
UBOOT_BINLOAD := u-boot-with-dtb.bin
else
UBOOT_BINLOAD := u-boot.bin
endif
endif
OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
–gap-fill=0xff
u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) 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=0xff
u-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.
ifndef PLATFORM_ELFENTRY
PLATFORM_ELFENTRY = “_start”
endif
quiet_cmd_u-boot-elf ?= LD $@
cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o KaTeX parse error: Expected 'EOF', got '\ ' at position 3: @ \̲ ̲ --defsym=(PLATFORM_ELFENTRY)=KaTeX parse error: Expected 'EOF', got '\ ' at position 24: …SYS_TEXT_BASE) \̲ ̲ -Ttext=(CONFIG_SYS_TEXT_BASE)
u-boot.elf: u-boot.bin
(
Q
)
(Q)
(Q)(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o
$(call if_changed,u-boot-elf)
MediaTek’s ARM-based u-boot needs a header to contains its load address
which is parsed by the BootROM.
If the SPL build is enabled, the header will be added to the spl binary,
and the spl binary and the u-boot.img will be combined into one file.
Otherwise the header will be added to the u-boot.bin directly.
ifeq ($(CONFIG_SPL),y)
spl/u-boot-spl-mtk.bin: spl/u-boot-spl
u-boot-mtk.bin: u-boot.dtb u-boot.img spl/u-boot-spl-mtk.bin FORCE
$(call if_changed,binman)
else
MKIMAGEFLAGS_u-boot-mtk.bin = -T mtk_image
-a $(CONFIG_SYS_TEXT_BASE) -e KaTeX parse error: Expected 'EOF', got '\ ' at position 24: …SYS_TEXT_BASE) \̲ ̲ -n "(patsubst “%”,%,$(CONFIG_MTK_BROM_HEADER_INFO))"
u-boot-mtk.bin: u-boot.bin FORCE
$(call if_changed,mkimage)
endif
ARCH_POSTLINK := $(wildcard ( s r c t r e e ) / a r c h / (srctree)/arch/ (srctree)/arch/(ARCH)/Makefile.postlink)
Rule to link u-boot
May be overridden by arch/$(ARCH)/config.mk
quiet_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;
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
quiet_cmd_smap = GEN common/system_map.o
cmd_smap =
smap=$(call SYSTEM_MAP,u-boot) | \ awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'
;
$(CC) KaTeX parse error: Can't use function '\"' in math mode at position 25: … -DSYSTEM_MAP="\̲"̲${smap}""
-c $(srctree)/common/system_map.c -o common/system_map.o
u-boot: $(u-boot-init)
(
u
−
b
o
o
t
−
m
a
i
n
)
u
−
b
o
o
t
.
l
d
s
F
O
R
C
E
+
(u-boot-main) u-boot.lds FORCE +
(u−boot−main)u−boot.ldsFORCE+(call if_changed,u-boot__)
ifeq ($(CONFIG_KALLSYMS),y)
$(call cmd,smap)
$(call cmd,u-boot__) common/system_map.o
endif
ifeq ($(CONFIG_RISCV),y)
@tools/prelink-riscv $@ 0
endif
quiet_cmd_sym ?= SYM $@
cmd_sym ?= $(OBJDUMP) -t $< > $@
u-boot.sym: u-boot FORCE
$(call if_changed,sym)
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 language
PHONY += $(u-boot-dirs)
$(u-boot-dirs): prepare scripts
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(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 “
(
U
B
O
O
T
V
E
R
S
I
O
N
)
(UBOOTVERSION)
(UBOOTVERSION)
(
(
((CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))”
endef
Store (new) UBOOTRELEASE string in include/config/uboot.release
include/config/uboot.release: include/config/auto.conf 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 order
PHONY += 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.release
ifneq (
(
K
B
U
I
L
D
S
R
C
)
,
)
@
(KBUILD_SRC),) @
(KBUILDSRC),)@(kecho) ’ Using $(srctree) as source for U-Boot’
$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then
echo >&2 " KaTeX parse error: Expected 'EOF', got '\ ' at position 54: …ke mrproper'"; \̲ ̲ echo >&2 " i…(srctree)’ directory.";
/bin/false;
fi;
endif
prepare2 creates a makefile if using a separate output directory
prepare2: prepare3 outputmakefile cfg
prepare1: prepare2 $(version_h) KaTeX parse error: Expected 'EOF', got '\ ' at position 15: (timestamp_h) \̲ ̲ …(wildcard $(LDSCRIPT)),)
@echo >&2 " Could not find linker script."
@/bin/false
endif
ifeq ($(CONFIG_USE_DEFAULT_ENV_FILE),y)
prepare1: $(defaultenv_h)
endif
archprepare: prepare1 scripts_basic
prepare0: archprepare FORCE
(
Q
)
(Q)
(Q)(MAKE) $(build)=.
All the preparing…
prepare: prepare0
Generate some files
---------------------------------------------------------------------------
define filechk_version.h
(echo #define PLAIN_VERSION “KaTeX parse error: Can't use function '\"' in math mode at position 15: (UBOOTRELEASE)\̲"̲; \ echo \#def…$(LC_ALL=C KaTeX parse error: Can't use function '\"' in math mode at position 28: …on | head -n 1)\̲"̲; \ echo \#def…$(LC_ALL=C $(LD) --version | head -n 1)”; )
endef
The SOURCE_DATE_EPOCH mechanism requires a date that behaves like GNU date.
The BSD date on the other hand behaves different and would produce errors
with the misused ‘-d’ switch. Respect that and search a working date with
well known pre- and suffixes for the GNU variant of date.
define filechk_timestamp.h
(if test -n “KaTeX parse error: Expected 'EOF', got '\ ' at position 28: …_EPOCH}"; then \̲ ̲ SOURCE_DATE="…{SOURCE_DATE_EPOCH}”;
DATE="";
for date in gdate date.gnu date; do
d
a
t
e
−
u
−
d
"
{date} -u -d "
date−u−d"{SOURCE_DATE}" >/dev/null 2>&1 && DATE="KaTeX parse error: Expected 'EOF', got '\ ' at position 10: {date}"; \̲ ̲ done; \ if …{DATE}"; then
LC_ALL=C
D
A
T
E
−
u
−
d
"
{DATE} -u -d "
DATE−u−d"{SOURCE_DATE}" +’#define U_BOOT_DATE “%b %d %C%y”’;
LC_ALL=C
D
A
T
E
−
u
−
d
"
{DATE} -u -d "
DATE−u−d"{SOURCE_DATE}" +’#define U_BOOT_TIME “%T”’;
LC_ALL=C
D
A
T
E
−
u
−
d
"
{DATE} -u -d "
DATE−u−d"{SOURCE_DATE}" +’#define U_BOOT_TZ “%z”’;
LC_ALL=C
D
A
T
E
−
u
−
d
"
{DATE} -u -d "
DATE−u−d"{SOURCE_DATE}" +’#define U_BOOT_DMI_DATE “%m/%d/%Y”’;
LC_ALL=C
D
A
T
E
−
u
−
d
"
{DATE} -u -d "
DATE−u−d"{SOURCE_DATE}" +’#define U_BOOT_BUILD_DATE 0x%Y%m%d’;
else
return 42;
fi;
else
LC_ALL=C date +’#define U_BOOT_DATE “%b %d %C%y”’;
LC_ALL=C date +’#define U_BOOT_TIME “%T”’;
LC_ALL=C date +’#define U_BOOT_TZ “%z”’;
LC_ALL=C date +’#define U_BOOT_DMI_DATE “%m/%d/%Y”’;
LC_ALL=C date +’#define U_BOOT_BUILD_DATE 0x%Y%m%d’;
fi)
endef
define filechk_defaultenv.h
(grep -v ‘^#’ |
grep -v ‘^$$’ |
tr ‘\n’ ‘\0’ |
sed -e ‘s/\\x0/\n/’ |
xxd -i ; echo “, 0x00” ; )
endef
$(version_h): include/config/uboot.release FORCE
$(call filechk,version.h)
$(timestamp_h): $(srctree)/Makefile FORCE
$(call filechk,timestamp.h)
$(defaultenv_h): $(CONFIG_DEFAULT_ENV_FILE:"%"=%) FORCE
$(call filechk,defaultenv.h)
---------------------------------------------------------------------------
quiet_cmd_cpp_lds = LDS $@
cmd_cpp_lds =
(
C
P
P
)
−
W
p
,
−
M
D
,
(CPP) -Wp,-MD,
(CPP)−Wp,−MD,(depfile) $(cpp_flags) $(LDPPFLAGS)
-D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -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
$(if
(
C
O
N
F
I
G
O
F
S
E
P
A
R
A
T
E
)
(CONFIG_OF_SEPARATE)
(CONFIGOFSEPARATE)(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb)
$(if
(
C
O
N
F
I
G
O
F
S
E
P
A
R
A
T
E
)
(CONFIG_OF_SEPARATE)
(CONFIGOFSEPARATE)(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)
(
Q
)
(Q)
(Q)(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
spl/sunxi-spl.bin: spl/u-boot-spl
@:
spl/sunxi-spl-with-ecc.bin: spl/sunxi-spl.bin
@:
spl/u-boot-spl.sfp: spl/u-boot-spl
@:
spl/boot.bin: spl/u-boot-spl
@:
tpl/u-boot-tpl.bin: tools prepare
$(if
(
C
O
N
F
I
G
O
F
S
E
P
A
R
A
T
E
)
(CONFIG_OF_SEPARATE)
(CONFIGOFSEPARATE)(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb)
(
Q
)
(Q)
(Q)(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
TAG_SUBDIRS := ( p a t s u b s t (patsubst %, (patsubst(srctree)/%,$(u-boot-dirs) include)
FIND := find
FINDFLAGS := -L
tags ctags:
ctags -w -o ctags $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ -name '*.[chS]' -print
ln -s ctags tags
etags:
etags -a -o etags $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ -name '*.[chS]' -print
cscope:
$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name ‘*.[chS]’ -print >
cscope.files
cscope -b -q -k
SYSTEM_MAP =
$(NM) KaTeX parse error: Expected 'EOF', got '\ ' at position 5: 1 | \̲ ̲ grep -v '\(co…KaTeX parse error: Can't use function '\)' in math mode at position 1: \̲)̲\|\( [aUw] \)\|…KaTeX parse error: Can't use function '\)' in math mode at position 1: \̲)̲\|\(LASH[RL]DI\…(call SYSTEM_MAP,$<) > $@
#########################################################################
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 “KaTeX parse error: Expected 'EOF', got '\ ' at position 31: …M_RELATIVE" -a \̲ ̲ "RELOC” != “R_AARCH64_RELATIVE”; then
echo “$< contains unexpected relocations: $$RELOC”;
false;
fi
envtools: scripts_basic $(version_h) $(timestamp_h)
(
Q
)
(Q)
(Q)(MAKE) $(build)=tools/env
tools-only: scripts_basic $(version_h) $(timestamp_h)
(
Q
)
(Q)
(Q)(MAKE) $(build)=tools
tools-all: export HOST_TOOLS_ALL=y
tools-all: envtools tools ;
cross_tools: export CROSS_BUILD_TOOLS=y
cross_tools: tools ;
.PHONY : CHANGELOG
CHANGELOG:
git log --no-merges U-Boot-1_1_5… |
unexpand -a | sed -e ‘s/\s\s*$$//’ > $@
#########################################################################
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)
$(foreach d, spl tpl,
(
p
a
t
s
u
b
s
t
(patsubst %,
(patsubstd/%,
$(filter-out include, $(shell ls -1 $d 2>/dev/null))))
CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h
boot* u-boot* MLO* SPL System.map fit-dtb.blob
Directories & files removed with ‘make mrproper’
MRPROPER_DIRS += include/config include/generated spl tpl
.tmp_objdiff
MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h
ctags etags tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
drivers/video/fonts/*.S
clean - Delete most, but leave enough to build external modules
clean: rm-dirs := $(CLEAN_DIRS)
clean: rm-files := $(CLEAN_FILES)
clean-dirs := ( f o r e a c h f , (foreach f, (foreachf,(u-boot-alldirs),$(if $(wildcard ( s r c t r e e ) / (srctree)/ (srctree)/f/Makefile),$f))
clean-dirs := $(addprefix clean, $(clean-dirs))
PHONY += $(clean-dirs) clean archclean
$(clean-dirs):
(
Q
)
(Q)
(Q)(MAKE)
(
c
l
e
a
n
)
=
(clean)=
(clean)=(patsubst clean%,%,$@)
clean: $(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 ‘..d’ -o -name '..tmp’ -o -name ‘.mod.c’
-o -name '.lex.c’ -o -name ‘.tab.[ch]’
-o -name '.symtypes’ -o -name ‘modules.order’
-o -name modules.builtin -o -name ‘.tmp_.o.’
-o -name ‘dsdt.aml’ -o -name ‘dsdt.asl.tmp’ -o -name ‘dsdt.c’
-o -name ‘.efi’ -o -name '.gcno’ -o -name ‘*.so’ )
-type f -print | xargs rm -f
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
)
(Q)
(Q)(MAKE)
(
c
l
e
a
n
)
=
(clean)=
(clean)=(patsubst mrproper%,%,$@)
mrproper: clean $(mrproper-dirs)
$(call cmd,rmdirs)
$(call cmd,rmfiles)
@rm -f arch/*/include/asm/arch
distclean
PHONY += distclean
distclean: 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 -f
@rm -f boards.cfg CHANGELOG
backup:
F=basename $(srctree)
; cd … ;
gtar --force-local -zcvf LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"
$$F
help:
@echo ‘Cleaning targets:’
@echo ’ clean - 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 ‘’
@echo ‘Configuration targets:’
@$(MAKE) -f
(
s
r
c
t
r
e
e
)
/
s
c
r
i
p
t
s
/
k
c
o
n
f
i
g
/
M
a
k
e
f
i
l
e
h
e
l
p
@
e
c
h
o
′
′
@
e
c
h
o
′
T
e
s
t
t
a
r
g
e
t
s
:
′
@
e
c
h
o
′
′
@
e
c
h
o
′
c
h
e
c
k
−
R
u
n
a
l
l
a
u
t
o
m
a
t
e
d
t
e
s
t
s
t
h
a
t
u
s
e
s
a
n
d
b
o
x
′
@
e
c
h
o
′
q
c
h
e
c
k
−
R
u
n
q
u
i
c
k
a
u
t
o
m
a
t
e
d
t
e
s
t
s
t
h
a
t
u
s
e
s
a
n
d
b
o
x
′
@
e
c
h
o
′
′
@
e
c
h
o
′
O
t
h
e
r
g
e
n
e
r
i
c
t
a
r
g
e
t
s
:
′
@
e
c
h
o
′
a
l
l
−
B
u
i
l
d
a
l
l
n
e
c
e
s
s
a
r
y
i
m
a
g
e
s
d
e
p
e
n
d
i
n
g
o
n
c
o
n
f
i
g
u
r
a
t
i
o
n
′
@
e
c
h
o
′
t
e
s
t
s
−
B
u
i
l
d
U
−
B
o
o
t
f
o
r
s
a
n
d
b
o
x
a
n
d
r
u
n
t
e
s
t
s
′
@
e
c
h
o
′
∗
u
−
b
o
o
t
−
B
u
i
l
d
t
h
e
b
a
r
e
u
−
b
o
o
t
′
@
e
c
h
o
′
d
i
r
/
−
B
u
i
l
d
a
l
l
f
i
l
e
s
i
n
d
i
r
a
n
d
b
e
l
o
w
′
@
e
c
h
o
′
d
i
r
/
f
i
l
e
.
[
o
i
s
S
]
−
B
u
i
l
d
s
p
e
c
i
f
i
e
d
t
a
r
g
e
t
o
n
l
y
′
@
e
c
h
o
′
d
i
r
/
f
i
l
e
.
l
s
t
−
B
u
i
l
d
s
p
e
c
i
f
i
e
d
m
i
x
e
d
s
o
u
r
c
e
/
a
s
s
e
m
b
l
y
t
a
r
g
e
t
o
n
l
y
′
@
e
c
h
o
′
(
r
e
q
u
i
r
e
s
a
r
e
c
e
n
t
b
i
n
u
t
i
l
s
a
n
d
r
e
c
e
n
t
b
u
i
l
d
(
S
y
s
t
e
m
.
m
a
p
)
)
′
@
e
c
h
o
′
t
a
g
s
/
c
t
a
g
s
−
G
e
n
e
r
a
t
e
c
t
a
g
s
f
i
l
e
f
o
r
e
d
i
t
o
r
s
′
@
e
c
h
o
′
e
t
a
g
s
−
G
e
n
e
r
a
t
e
e
t
a
g
s
f
i
l
e
f
o
r
e
d
i
t
o
r
s
′
@
e
c
h
o
′
c
s
c
o
p
e
−
G
e
n
e
r
a
t
e
c
s
c
o
p
e
i
n
d
e
x
′
@
e
c
h
o
′
u
b
o
o
t
r
e
l
e
a
s
e
−
O
u
t
p
u
t
t
h
e
r
e
l
e
a
s
e
v
e
r
s
i
o
n
s
t
r
i
n
g
(
u
s
e
w
i
t
h
m
a
k
e
−
s
)
′
@
e
c
h
o
′
u
b
o
o
t
v
e
r
s
i
o
n
−
O
u
t
p
u
t
t
h
e
v
e
r
s
i
o
n
s
t
o
r
e
d
i
n
M
a
k
e
f
i
l
e
(
u
s
e
w
i
t
h
m
a
k
e
−
s
)
′
@
e
c
h
o
"
c
f
g
−
D
o
n
′
t
b
u
i
l
d
,
j
u
s
t
c
r
e
a
t
e
t
h
e
.
c
f
g
f
i
l
e
s
"
@
e
c
h
o
"
e
n
v
t
o
o
l
s
−
B
u
i
l
d
o
n
l
y
t
h
e
t
a
r
g
e
t
−
s
i
d
e
e
n
v
i
r
o
n
m
e
n
t
t
o
o
l
s
"
@
e
c
h
o
′
′
@
e
c
h
o
′
S
t
a
t
i
c
a
n
a
l
y
s
e
r
s
′
@
e
c
h
o
′
c
h
e
c
k
s
t
a
c
k
−
G
e
n
e
r
a
t
e
a
l
i
s
t
o
f
s
t
a
c
k
h
o
g
s
′
@
e
c
h
o
′
c
o
c
c
i
c
h
e
c
k
−
E
x
e
c
u
t
e
s
t
a
t
i
c
c
o
d
e
a
n
a
l
y
s
i
s
w
i
t
h
C
o
c
c
i
n
e
l
l
e
′
@
e
c
h
o
′
′
@
e
c
h
o
′
D
o
c
u
m
e
n
t
a
t
i
o
n
t
a
r
g
e
t
s
:
′
@
(srctree)/scripts/kconfig/Makefile help @echo '' @echo 'Test targets:' @echo '' @echo ' check - Run all automated tests that use sandbox' @echo ' qcheck - Run quick automated tests that use sandbox' @echo '' @echo 'Other generic targets:' @echo ' all - Build all necessary images depending on configuration' @echo ' tests - Build U-Boot for sandbox and run tests' @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/ctags - Generate ctags file for editors' @echo ' etags - Generate etags file for editors' @echo ' cscope - Generate cscope index' @echo ' ubootrelease - Output the release version string (use with make -s)' @echo ' ubootversion - Output the version stored in Makefile (use with make -s)' @echo " cfg - Don't build, just create the .cfg files" @echo " envtools - Build only the target-side environment tools" @echo '' @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo ' coccicheck - Execute static code analysis with Coccinelle' @echo '' @echo 'Documentation targets:' @
(srctree)/scripts/kconfig/Makefilehelp@echo′′@echo′Testtargets:′@echo′′@echo′check−Runallautomatedteststhatusesandbox′@echo′qcheck−Runquickautomatedteststhatusesandbox′@echo′′@echo′Othergenerictargets:′@echo′all−Buildallnecessaryimagesdependingonconfiguration′@echo′tests−BuildU−Bootforsandboxandruntests′@echo′∗u−boot−Buildthebareu−boot′@echo′dir/−Buildallfilesindirandbelow′@echo′dir/file.[oisS]−Buildspecifiedtargetonly′@echo′dir/file.lst−Buildspecifiedmixedsource/assemblytargetonly′@echo′(requiresarecentbinutilsandrecentbuild(System.map))′@echo′tags/ctags−Generatectagsfileforeditors′@echo′etags−Generateetagsfileforeditors′@echo′cscope−Generatecscopeindex′@echo′ubootrelease−Outputthereleaseversionstring(usewithmake−s)′@echo′ubootversion−OutputtheversionstoredinMakefile(usewithmake−s)′@echo"cfg−Don′tbuild,justcreatethe.cfgfiles"@echo"envtools−Buildonlythetarget−sideenvironmenttools"@echo′′@echo′Staticanalysers′@echo′checkstack−Generatealistofstackhogs′@echo′coccicheck−ExecutestaticcodeanalysiswithCoccinelle′@echo′′@echo′Documentationtargets:′@(MAKE) -f $(srctree)/Documentation/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
C
H
E
C
K
(
s
p
a
r
s
e
b
y
d
e
f
a
u
l
t
)
′
@
e
c
h
o
′
m
a
k
e
C
=
2
[
t
a
r
g
e
t
s
]
F
o
r
c
e
c
h
e
c
k
o
f
a
l
l
c
s
o
u
r
c
e
w
i
t
h
CHECK (sparse by default)' @echo ' make C=2 [targets] Force check of all c source with
CHECK(sparsebydefault)′@echo′makeC=2[targets]ForcecheckofallcsourcewithCHECK’
@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’
tests check:
$(srctree)/test/run
qcheck:
$(srctree)/test/run quick
Documentation targets
---------------------------------------------------------------------------
DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs
linkcheckdocs dochelp refcheckdocs
PHONY += $(DOC_TARGETS)
$(DOC_TARGETS): scripts_basic FORCE
(
Q
)
(Q)
(Q)(MAKE) $(build)=Documentation $@
endif #ifeq (KaTeX parse error: Expected 'EOF', got '#' at position 27: …gets),1) endif #̲ifeq ((mixed-targets),1)
PHONY += checkstack ubootrelease ubootversion
checkstack:
$(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) |
$(PERL) $(src)/scripts/checkstack.pl $(ARCH)
ubootrelease:
@echo “
(
U
B
O
O
T
V
E
R
S
I
O
N
)
(UBOOTVERSION)
(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 use
ifeq ($(KBUILD_EXTMOD),)
build-dir =
(
p
a
t
s
u
b
s
t
(patsubst %/,%,
(patsubst(dir $@))
target-dir = $(dir
@
)
e
l
s
e
z
a
p
−
s
l
a
s
h
=
@) else zap-slash=
@)elsezap−slash=(filter-out .,
(
p
a
t
s
u
b
s
t
(patsubst %/,%,
(patsubst(dir $@)))
build-dir =
(
K
B
U
I
L
D
E
X
T
M
O
D
)
(KBUILD_EXTMOD)
(KBUILDEXTMOD)(if
(
z
a
p
−
s
l
a
s
h
)
,
/
(zap-slash),/
(zap−slash),/(zap-slash))
target-dir = $(if
(
K
B
U
I
L
D
E
X
T
M
O
D
)
,
(KBUILD_EXTMOD),
(KBUILDEXTMOD),(dir
<
)
,
<),
<),(dir $@))
endif
%.s: %.c prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
%.i: %.c prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
%.o: %.c prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
%.lst: %.c prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
%.s: %.S prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
%.o: %.S prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
%.symtypes: %.c prepare scripts FORCE
(
Q
)
(Q)
(Q)(MAKE)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
(
t
a
r
g
e
t
−
d
i
r
)
(target-dir)
(target−dir)(notdir $@)
Modules
/: prepare scripts FORCE
$(cmd_crmodverdir)
(
Q
)
(Q)
(Q)(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
%/: prepare scripts FORCE
$(cmd_crmodverdir)
(
Q
)
(Q)
(Q)(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir)
%.ko: prepare scripts FORCE
$(cmd_crmodverdir)
(
Q
)
(Q)
(Q)(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)
(
b
u
i
l
d
)
=
(build)=
(build)=(build-dir) $(@:.ko=.o)
(
Q
)
(Q)
(Q)(MAKE) -f $(srctree)/scripts/Makefile.modpost
Consistency checks
---------------------------------------------------------------------------
PHONY += coccicheck
coccicheck:
(
Q
)
(Q)
(Q)(CONFIG_SHELL)
(
s
r
c
t
r
e
e
)
/
s
c
r
i
p
t
s
/
(srctree)/scripts/
(srctree)/scripts/@
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 lines
targets := $(wildcard $(sort $(targets)))
cmd_files := $(wildcard .*.cmd
(
f
o
r
e
a
c
h
f
,
(foreach f,
(foreachf,(targets),$(dir
(
f
)
)
.
(f)).
(f)).(notdir $(f)).cmd))
ifneq ($(cmd_files),)
$(cmd_files): ; # Do not try to update included dependency files
include $(cmd_files)
endif
endif # skip-makefile
PHONY += FORCE
FORCE:
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)