Linux内核scripts/Makefile.build文件结构

1. 默认目标__build

2. 初始化obj-y、obj-m等变量

3. -include include/config/auto.conf
 内含CONFIG_RING_BUFFER=y等变量列表

4. include scripts/Kbuild.include
 内含各辅助函数、变量的定义
 如变量build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj

5. include $(kbuild-file)
 变量obj传进来目录内的Makefile(或Kbuild优先)

6. include scripts/Makefile.lib
 内含c_flags、a_flags各编译标志变量
 处理obj-y、obj-m等变量

7. 若有$(hostprogs-y)或$(hostprogs-m)需要编译主机程序,则include scripts/Makefile.host

8. builtin-target、lib-target、modorder-target

9. __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
  $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
  $(subdir-ym) $(always)

10. .c、.S等文件的编译规则

11. 递归进入子目录的规则
 $(subdir-ym):
  $(Q)$(MAKE) $(build)=$@

 

 

通常内核各个文件都是由-f参数使用scripts/Makefile.build文件来作为Makefile进行目标的编译

对目标的编译主要使用如下格式:

$(Q)$(MAKE) $(build)=目录 [目标]

build变量在scripts/Kbuild.include中定义

展开即:

make -f scripts/Makefile.build obj=目录 [目标]

 

 

你可能感兴趣的:(Linux内核scripts/Makefile.build文件结构)