使用make dtbs命令时
在arch/arm 的目录Makefile文件中有
boot := arch/arm/boot
prepare 和scripts是空的
在文件scripts/Kbuild.include中
变量build := -f $(srctree)/scripts/Makefile.build obj
在顶层Makefile中
$(srctree):=.
展开后-f ./scripts/Makefile.build obj:=arch/arm/boot/dts
通过下面的命令包含传入的$(obj)目录下的Makefile,即arch/arm/boot/dts/Makefile
The filename Kbuild has precedence over Makefile
kbuild-dir := $(if (filter /%,(src)),(src),(srctree)/$(src))
kbuild-file := $(if $(wildcard (kbuild-dir)/Kbuild),(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
include $(kbuild-file)
-f 的作用是使用make 命令编译由-f 指定的Makefile文件(scripts/Makefile.build)
在该文件中使用默认目标__build,
展开后使用
__build: $(builtin-target) $(lib-target) $(extra-y)) $(subdir-ym) $(always)
@:
其中 $(always)在arch/arm/boot/dts/Makefile中
always := $(dtb-y)
$(dtb-y)就是我们要编译的目标.dtb。
至此,流程为
Make dtbs ->
make -f ./scripts/Makefile.build obj:=arch/arm/boot/dts
->__build: $(builtin-target) $(lib-target) $(extra-y)) $(subdir-ym) $(always)
->include $(kbuild-file)
->always := $(dtb-y)
dtbs 依赖$(dtb-y)