# note:顶层MakefileKBUILD_MODULES :=
综上:语句$(if $ (KBUILD_MODULES),$(obj-m) $(modorder-target))为空 。
4.1.3 $(subdir-ym)在scripts/Makefile.lib中,subdir-ym的定义如下:
# note:scripts/Makefile.lib# Subdirectories we need to descend intosubdir-ym := $(sort $(subdir-y) $(subdir-m))......subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
subdir-y与subdir-m都为空 。综上:语句$(subdir-ym)为空 。
4.1.4 $(always) 重点关注在scripts/Makefile.build有如下定义
# note:scripts/Makefile.build# The filename Kbuild has precedence over Makefilekbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)include $(kbuild-file)
4.1.4.1 src的定义在scripts/Makefile.build有如下定义
# note:scripts/Makefile.build# Modified for U-Bootprefix := tplsrc := $(patsubst $(prefix)/%,%,$(obj))ifeq ($(obj),$(src))prefix := splsrc := $(patsubst $(prefix)/%,%,$(obj))ifeq ($(obj),$(src))prefix := .endifendif
在命令make -f ./scripts/Makefile.build obj=scripts/basic我们传入了obj=scripts/basic 所以src = https://www.huyubaike.com/biancheng/obj = scripts/basic, prefix := .
4.1.4.2 kbuild-dir的定义在scripts/Makefile.build有如下定义
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
所以 kbuild-dir = ./scripts/basic
4.1.4.3 kbuild-file的定义在scripts/Makefile.build有如下定义
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
所以kbuild-file = ./scripts/basic/Makefile
所以include $(kbuild-file)即为include ./scripts/basic/Makefile
在./scripts/basic/Makefile中:
# note:scripts/basic/Makefilehostprogs-y := fixdepalways:= $(hostprogs-y)# fixdep is needed to compile other host programs$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
所以always = fixdep
4.1.4.4 又在Makefile.build中包含include scripts/Makefile.lib而在scripts/Makefile.lib中
# note:scripts/Makefile.libalways:= $(addprefix $(obj)/,$(always))
所以最终 always = scripts/basic/fixdep。
故__build 展开如下: __build: scripts/basic/fixdep@:1. 在Makefile.build中有如下定义:
# note:scripts/Makefile.buildifneq ($(hostprogs-y)$(hostprogs-m),)include scripts/Makefile.hostendif
在./scripts/basic/Makefile中hostprogs-y = fixdep, 所以scripts/Makefile.host被包含进Makefile.build;在scripts/Makefile.host中# note:scripts/Makefile.host__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
hostprogs-m为空,所以__hostprogs = fixdep 。在scripts/Makefile.host中# note:scripts/Makefile.host# C code# Executables compiled from a single .c filehost-csingle := $(foreach m,$(__hostprogs), \$(if $($(m)-objs)$($(m)-cxxobjs)$($(m)-sharedobjs),,$(m)))......host-csingle := $(addprefix $(obj)/,$(host-csingle))
因为fixdep-objs与fixdep-cxxobjs都不存在,所以host-csingle = fixdep; 又 host-csingle := $ (addprefix $ (obj)/,$(host-csingle)),所以host-csingle = scripts/basic/fixdep 。host-csingle规则如下:# note:scripts/Makefile.host$(host-csingle): $(obj)/%: $(src)/%.c FORCE $(call if_changed_dep,host-csingle)
等价于:scripts/basic/fixdep:scripts/basic/fixdep.c FORCE$(call if_changed_dep,host-csingle)
2. if_changed_dep在scripts/Kbuild.include中定义# note:scripts/Kbuild.include# Execute the command and also postprocess 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)
经验总结扩展阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Ubuntu安装Docker及镜像加速器
- 2023年1月29日拆房好不好 2023年1月29日拆房吉日一览表
- 2023年1月29日搬新家吉日一览表 2023年1月29日是搬新家吉日吗
- 2023年1月29日拆迁吉日一览表 2023年农历正月初八宜拆迁吗
- 2023年农历正月初八宜乔迁吗 2023年1月29日乔迁吉日一览表
- 精选600个 唐姓女孩名字2023年属兔
- 取一个寓意好的名字 2023年女宝宝名字库300个
- 水果店名字独一无二 大气的水果店名字
- 丁火男喜欢一个人的表现 疼爱有加情投意合
- 适合文科内向男孩的专业有什么 学什么专业有前途