1 make -f scripts/Makefile.buildobj=scripts/basic
gcc -Wp,-MD,scripts/basic/.fixdep.d-Wall -Wmissing-prototypes -Wstrict-prototypes -O2-fomit-frame-pointer -o scripts/basic/fixdepscripts/basic/fixdep.c
gcc -Wp,-MD,scripts/basic/.docproc.d-Wall -Wmissing-prototypes -Wstrict-prototypes -O2-fomit-frame-pointer -o scripts/basic/docprocscripts/basic/docproc.c
rm -f .tmp_quiet_recordmcount
2 在makefile.build中
__build: $(if$(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
$(if $(KBUILD_MODULES),$(obj-m)$(modorder-target)) \
$(subdir-ym) $(always)
@:
在scripts/basic/Makefile中定义
hostprogs-y := fixdep docproc
always := $(hostprogs-y)
而生成fixdepdocproc 的规则在Makefile.host中定义。
3 分析Makefile.host
此文件中定义了一些规则在hostsystem上生成二进制文件,在内核编译过程中会用到这些二进制文件,如文件的预处理。
hostprogs-y=fixdep docproc
__hostprogs := $(sort $(hostprogs-y)$(hostprogs-m))
host-cmulti := $(foreachm,$(__hostprogs),$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
若$($(m)-cxxobjs)为非空则返回空,若为空则返回$(if$($(m)-objs),$(m)),$($(m)-objs)为空返回空,因此host-cmulti为空的。
$($(m)-objs),并没有定义 fixdep-objs或 hostprogs-objs因此为空。
Targets什么用????
接下来它会执行这条规则:
quiet_cmd_host-csingle = HOSTCC $@
cmd_host-csingle = $(HOSTCC)$(hostc_flags) -o $@ $< \
$(HOST_LOADLIBES)$(HOSTLOADLIBES_$(@F))
$(host-csingle): $(obj)/%: $(src)/%.cFORCE
$(call if_changed_dep,host-csingle)
其规则是在cmd_host-csingle中定义的,在调用的if_changed_dep函数中最终是调用了cmd_host-csingle生成目标文件fixdep和docproc
if_changed_dep在scripts/Kbuild.include中
# Execute the command and alsopostprocess generated .d dependencies file.
if_changed_dep = $(if $(strip$(any-prereq) $(arg-check) ), \
@set -e; \
$(echo-cmd) $(cmd_$(1)); \
scripts/basic/fixdep $(depfile) $@'$(make-cmd)' > $(dot-target).tmp;\
rm -f $(depfile); \
mv -f $(dot-target).tmp$(dot-target).cmd)
# if_changed - execute command ifany prerequisite is newer than
# target, or commandline has changed
# if_changed_dep - as if_changed, butuses fixdep to reveal dependencies
# including usedconfig symbols
# if_changed_rule - as if_changed butexecute rule instead
fixdep docproc 二者分别什么作用???