VERSION = 2016 #版本号
PATCHLEVEL = 03 #补丁版本号
SUBLEVEL = #次版本号
EXTRAVERSION = #附加版本信息
NAME = #名字
MAKEFLAGS += -rR --include-dir=$(CURDIR)
#“+=”来给变量 MAKEFLAGS 追加了一些值,“-rR”表示禁止使用内置的隐含规则和变量定义,
#“--include-dir”指明搜索路径,”$(CURDIR)”表示当前目录。
#“SHELL”和“MAKEFLAGS”,这两个变量除非使用“unexport”声明,否则的话在整个 make 的执行过程中,
#它们的值始终自动的传递给子 make。
# Avoid funny character set dependencies
unexport LC_ALL #不导出变量给子make
LC_COLLATE=C
LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC #导出变量给子make
# Avoid interference with shell env settings
unexport GREP_OPTIONS
ifeq ("$(origin V)", "command line") #判断是否相等 o(origin)就是变量来源
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
#用变量 quiet 和 Q 来控制编译的时候是否在终端输出完整的命令
ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
else
quiet=quiet_ #显示短命令
Q = @
endif
# If the user is running make -s (silent mode), suppress echoing of
# commands
ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 filter是过滤的,在变量中仅保留符合4.%的词
ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) #firstword 取出变量中首单词
quiet=silent_ #不显示命令
endif
else # make-3.8x
ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
quiet=silent_
endif
endif
export quiet Q KBUILD_VERBOSE
mytest:
@echo 'firstword=' $(firstword x$(MAKEFLAGS)) #有@就不会在终端输出命令
export srctree objtree VPATH #导出变量
# Make sure CDPATH settings don't interfere
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/)
# shell中的|表示通道,意思是将左边的输出作为右边的输入。sed -e是替换命令,uname -m获取架构,uname -s获取OS
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed -e 's/\(cygwin\).*/cygwin/')
#tr '[:upper:]' '[:lower:]' 把大写字母替换为小写字母
export HOSTARCH HOSTOS