慢慢欣赏linux if_changed_xxx的作用

编译内核会生成很多临时文件,以 o.cmd为后缀。
打开看发现是编译脚本。
这些文件是在scripts/makefile.build文件通过如下编译宏实现:

define rule_cc_o_c
	$(call echo-cmd,checksrc) $(cmd_checksrc)			  \
	$(call echo-cmd,cc_o_c) $(cmd_cc_o_c);				  \
	$(cmd_modversions)						  \
	$(call echo-cmd,record_mcount)					  \
	$(cmd_record_mcount)						  \
	scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' >    \
	                                              $(dot-target).tmp;  \
	rm -f $(depfile);						  \
	mv -f $(dot-target).tmp $(dot-target).cmd
endef

调用者也在同一个文件(scripts/makefile.build),编译可执行程序和ko都会生成类似的临时文件

# Built-in and composite module parts
$(obj)/%.o: $(src)/%.c FORCE
	$(call cmd,force_checksrc)
	$(call if_changed_rule,cc_o_c)

# Single-part modules are special since we need to mark them in $(MODVERDIR)

$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE
	$(call cmd,force_checksrc)
	$(call if_changed_rule,cc_o_c)
	@{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod)

u-boot-2016.09 make工具之fixdep
https://blog.csdn.net/guyongqiangx/article/details/52588409

【u-boot-2018.11】make工具之fixdep
https://blog.csdn.net/linuxweiyh/article/details/100179968

内核编译系统探秘之一 if_changed_rule
http://blog.sina.com.cn/s/blog_61c81f910100phiq.html

Uboot 中make menuconfig 做了什么?
https://www.cnblogs.com/syyxy/p/9350999.html

内核Kbuild 学习
http://blog.chinaunix.net/uid-20778443-id-103963.html
http://www.360doc.com/content/12/0107/15/6828497_177891385.shtml

Linux之Makefile(strip)
https://blog.csdn.net/zhoudengqing/article/details/41777665

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章