OpenWRT Makefile流程记录

$(toolchain/stamp-install): $(tools/stamp-install)

通过subdir.mk的stampfile函数
$(eval $(call stampfile,$(curdir),tools,install,,_$(subst $(space),,$(tools_enabled))))
展开
define stampfile
  $(1)/stamp-$(3):=$(if $(6),$(6),$(STAGING_DIR))/stamp/.$(2)_$(3)$(5)
  $$($(1)/stamp-$(3)): $(TMP_DIR)/.build $(4)
    @+$(SCRIPT_DIR)/timestamp.pl -n $$($(1)/stamp-$(3)) $(1) $(4) || \
        $(MAKE) $(if $(QUIET),--no-print-directory) $$($(1)/flags-$(3)) $(1)/$(3)
    @mkdir -p $$$$(dirname $$($(1)/stamp-$(3)))
    @touch $$($(1)/stamp-$(3))

  $$(if $(call debug,$(1),v),,.SILENT: $$($(1)/stamp-$(3)))

  .PRECIOUS: $$($(1)/stamp-$(3)) # work around a make bug

  $(1)//clean:=$(1)/stamp-$(3)/clean
  $(1)/stamp-$(3)/clean: FORCE
    @rm -f $$($(1)/stamp-$(3))
endef

tools/stamp-install:= $(STAGING_DIR)/stamp/.tools_install_yyynnnyynnn
$(tools/stamp-install): tmp/.build
	make $(tools/flags-install) tools/install #通过subdir.mk的subdir函数展开产生规则
	tools/clean:=tools/stamp-install/clean
	tools/stamp-install/clean: FORCE
		rm -rf $(tools/stamp-install)

subdir展开关于clean有一个,如果clean则同时要执行tools/stamp-install/clean删除文件,其他命令不影响
tools/clean:  tools/stamp-install/clean
	@+ $(SUBMAKE) -r -C target/linux clean BUILD_VARIANT=""

 

posted on 2022-03-08 14:53  sudochen  阅读(301)  评论(0编辑  收藏  举报

导航