📄 makefile.txt
字号:
on exported symbols
# Separate the object into
"normal" objects and "exporting" objects
# Exporting objects are:
all objects that define symbol tables
#
ifdef CONFIG_MODULES
# list-multi列出那些由
多个文件复合而成的模块;
# 从编绎文件表和模块
文件表中过滤出复合模块名。
multi-used :=
$(filter $(list-multi),
$(obj-y) $(obj-m))
# 取复合模块的构成表。
multi-objs := $(foreach m,
$(multi-used), $($(basename $(m))-objs))
# 求出需进行编译的总模块表。
active-objs :=
$(sort $(multi-objs) $(obj-y) $(obj-m))
ifdef CONFIG_MODVERSIONS
ifneq "$(strip $(export-objs))" ""
# 如果有需要进行版本化的文件。
MODINCL =
$(TOPDIR)/include/linux/modules
# 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
#
ifdef CONFIG_SMP
genksyms_smp_prefix := -p smp_
else
genksyms_smp_prefix :=
endif
# 从源文件计算版本文件的规则。
$(MODINCL)/%.ver: %.c
@if [ ! -r $
(MODINCL)/$*.stamp -o $(MODINCL)
/$*.stamp -ot $< ]; then \
echo '$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<';
\
echo '| $(GENKSYMS) $(genksyms_smp_prefix) -k
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp';
\
$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<
\
| $(GENKSYMS) $(genksyms_smp_prefix) -k
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp;
\
if [ -r $@ ]
&& cmp -s $@ $@.tmp;
then echo $@ is unchanged; rm -f
$@.tmp;
\
else echo mv $@.tmp $@; mv -f $@.tmp $@; fi;
\
fi; touch $(MODINCL)/$*.stamp
#
将版本处理源文件的扩展名改为.ver,
并加上完整的路径名,
它们依赖于autoconf.h?br>?br>$(addprefix $(MODINCL)/,$(export-objs:.o=.ver)):
$(TOPDIR)/include/linux/autoconf.h
# 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 $(T
OPDIR)/include/linux
/modversions.h.tmp
$(TOPDIR)/include
/linux/modversions.h; \
fi
$(active-objs):
$(TOPDIR)/include/linux/modversions.h
else
# 如果没有配置版本化,modversions.h的内容。
$(TOPDIR)/include/linux/modversions.h:
@echo "#include <linux/modsetver.h>" > $@
endif # CONFIG_MODVERSIONS
ifneq "$(strip $(export-objs))" ""
# 版本化目标文件的编绎方法。
$(export-objs): $(export-objs:.o=.c) $(TOPDIR)/include/linux/modversions.h
$(CC) $(CFLAGS)
$(EXTRA_CFLAGS)
$(CFLAGS_$@) -DEXPORT_SYMTAB -c
$(@:.o=.c)
@ ( \
echo 'ifeq ($(strip
$(subst $(comma),:,
$(CFLAGS) $(EXTRA_CFLAGS)
$(CFLAGS_$@) -DEXPORT_SYMTAB)),
$$(strip $$(subst $$(comma),:,
$$(CFLAGS)
$$(EXTRA_CFLAGS)
$$(CFLAGS_$@) -DEXPORT_SYMTAB)))'
; \
echo 'FILES_FLAGS_UP_TO_DATE +=
$@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
endif
endif # CONFIG_MODULES
#
# 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>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -