==========================================
Makefile解读之四: Rules.make的注释
==========================================
#
# This file contains rules which are shared between multiple Makefiles.
#
#
# False targets.
#
#
.PHONY: dummy
#
# Special variables which should not be exported
#
# 取消这些变量通过环境向make子进程传递。
unexport EXTRA_AFLAGS # as 的开关
unexport EXTRA_CFLAGS # cc 的开关
unexport EXTRA_LDFLAGS # ld 的开关
unexport EXTRA_ARFLAGS # ar 的开关
unexport SUBDIRS #
unexport SUB_DIRS # 编绎内核需进入的子目录,等于subdir-y
unexport ALL_SUB_DIRS # 所有的子目录
unexport MOD_SUB_DIRS # 编绎模块需进入的子目录
unexport O_TARGET # ld合并的输出对象
unexport ALL_MOBJS # 所有的模块名
# Old makefiles define their own rules for compiling .S files,
# but these standard rules are available for any Makefile that
# wants to use them. Our plan is to incrementally convert all
# the Makefiles to these standard rules. -- rmk, mec
# The -w option (enable warnings) for genksyms will return here in 2.1
# So where has it gone?
#
# Added the SMP separator to stop module accidents between uniprocessor
# and SMP Intel boxes - AC - from bits by Michael Chastain
#
# updates .ver files but not modversions.h
# 通过fastdep,逐个生成export-objs对应的版本文件。
fastdep: $(addprefix $(MODINCL)/,$(export-objs:.o=.ver))
# updates .ver files and modversions.h like before (is this needed?)
# make dep过程的入口
dep: fastdep update-modverfile
endif # export-objs
# update modversions.h, but only if it would change
# 刷新版本文件的过程。
update-modverfile:
@(echo "#ifndef _LINUX_MODVERSIONS_H";
echo "#define _LINUX_MODVERSIONS_H";
echo "#include <linux/modsetver.h>;";
cd $(TOPDIR)/include/linux/modules;
for f in *.ver; do
if [ -f $$f ]; then echo "#include <linux/modules/$${f}>;"; fi;
done;
echo "#endif";
) >; $(TOPDIR)/include/linux/modversions.h.tmp
@if [ -r $(TOPDIR)/include/linux/modversions.h ] && cmp -s
$(TOPDIR)/include/linux/modversions.h
$(TOPDIR)/include/linux/modversions.h.tmp; then
echo $(TOPDIR)/include/linux/modversions.h was not updated;
rm -f $(TOPDIR)/include/linux/modversions.h.tmp;
else
echo $(TOPDIR)/include/linux/modversions.h was updated;
mv -f $(TOPDIR)/include/linux/modversions.h.tmp
$(TOPDIR)/include/linux/modversions.h;
fi
$(active-objs): $(TOPDIR)/include/linux/modversions.h
#
# include dependency files if they exist
#
# 嵌入源文件之间的依赖关系。
ifneq ($(wildcard .depend),)
include .depend
endif
# 嵌入头文件之间的依赖关系。
ifneq ($(wildcard $(TOPDIR)/.hdepend),)
include $(TOPDIR)/.hdepend
endif
#
# Find files whose flags have changed and force recompilation.
# For safety, this works in the converse direction:
# every file is forced, except those whose flags are positively
up-to-date.
#
# 已经更新过的文件列表。
FILES_FLAGS_UP_TO_DATE :=
# For use in expunging commas from flags, which mung our checking.
comma = ,
# 将当前目录下所有flags文件嵌入。
FILES_FLAGS_EXIST := $(wildcard .*.flags)
ifneq ($(FILES_FLAGS_EXIST),)
include $(FILES_FLAGS_EXIST)
endif
# 将无需更新的文件从总的对象中删除。
FILES_FLAGS_CHANGED := $(strip
$(filter-out $(FILES_FLAGS_UP_TO_DATE),
$(O_TARGET) $(L_TARGET) $(active-objs)
))
# A kludge: .S files don't get flag dependencies (yet),
# because that will involve changing a lot of Makefiles. Also
# suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
# This allows handling of assembly files that get translated into
# multiple object files (see arch/ia64/lib/idiv.S, for example).
#
# 将由汇编文件生成的目件文件从FILES_FLAGS_CHANGED删除。
FILES_FLAGS_CHANGED := $(strip
$(filter-out $(patsubst %.S, %.o, $(wildcard *.S)
$(IGNORE_FLAGS_OBJS)),
$(FILES_FLAGS_CHANGED)))
# 将FILES_FLAGS_CHANGED设为目标。
ifneq ($(FILES_FLAGS_CHANGED),)
$(FILES_FLAGS_CHANGED): dummy
endif
</pre>;