https://blog.csdn.net/weixin_55255438/article/details/123562395
下面的源码为4.19内核
目录
Makefile的分类
https://blog.csdn.net/yuhaibin168/article/details/7470301
kernel编译流程
https://blog.csdn.net/jun_8018/article/details/112792967
https://blog.csdn.net/wsyangyue/article/details/82839701
https://www.cnblogs.com/parrynee/archive/2010/05/13/1734689.html
https://blog.csdn.net/yuhaibin168/article/details/7470301
https://zhuanlan.zhihu.com/p/78254770
config目标
%config 目标
https://zhuanlan.zhihu.com/p/362965954
https://blog.csdn.net/weixin_55255438/article/details/123562395
541 %config: scripts_basic outputmakefile FORCE
542 $(Q)$(MAKE) $(build)=scripts/kconfig $@
- 依赖目标1:scripts_basic
470 scripts_basic: 471 $(Q)$(MAKE) $(build)=scripts/basic 472 $(Q)rm -f .tmp_quiet_recordmcount
$(Q)$(MAKE) $(build)=scripts/basic
即make -f $(srctree)/scripts/Makefile.build obj=scripts/basic
,Makefile.build指出默认目标为__build
scripts/Makefile.build的开头会include变量 $(obj)
下的Makefile文件,其中就包含 scripts/basic/Makefile
:
6 src := $(obj)
42 # The filename Kbuild has precedence over Makefile
43 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
44 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
45 include $(kbuild-file)
scripts/basic/Makefile
复写了always变量
11 hostprogs-y := fixdep
12 always := $(hostprogs-y)
13
14 # fixdep is needed to compile other host programs
15 $(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
__build
目标依赖always变量, $(always) 的值就是 fixdep。
所以,scripts_basic 的目标就干了一件事:生成 fixdep。
-
依赖目标2:outputMakefile
481 outputmakefile: 482 ifneq ($(KBUILD_SRC),) #在kernel编译输出目录创建一个软链接,指向kernel源码根目录。 483 $(Q)ln -fsn $(srctree) source #将kernel源码根目录的Makefile文件复制到kernel编译输出目录 484 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ 485 $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) 486 endif
-
执行命令生成.config文件:
https://blog.csdn.net/weixin_39580564/article/details/116820658
$(Q)$(MAKE) $(build)=scripts/kconfig $@
假若make的目标为vendor/kona_defconfig
,则命令为make -f $(srctree)/scripts/Makefile.build obj=scripts/kconfig vendor/kona_defconfig
则vendor/kona_defconfig
目标定义在scripts/kconfig/Makefile
中
103 %_defconfig: $(obj)/conf
104 $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
先忽略$(obj)/conf
工具的编译过程
上面完整命令即为:$(Q)scripts/kconfig/conf $(silent) --defconfig=arch/$(SRCARCH)/configs/vendor/kona_defconfig Kconfig
,就会读取内核配置文件arch/$(SRCARCH)/configs/vendor/kona_defconfig
,然后生成.config文件,注意vendor/kona_defconfig
到.config
文件并不是简单的拷贝关系。
vmlinux目标(缺省目标,生成最原始的未压缩的内核镜像vmlinux)
https://blog.csdn.net/weixin_36098975/article/details/135140530 (***)
https://zhuanlan.zhihu.com/p/571078063
https://www.cnblogs.com/jianhua1992/p/16852799.html
vmlinux目标依赖图
https://zhuanlan.zhihu.com/p/646773422
内核镜像组成
https://blog.csdn.net/ldl617/article/details/126932099
https://blog.csdn.net/Lsq111112/article/details/129410284
vmlinx--->objcopy--->Image--->gzip--->arch/arm/boot/compressed/vmlinx--->objcopy--->zImage--->mkimage--->uImage
0 条评论