慢慢欣賞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

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