BuildRoot - Understanding how to rebuild packages(try know why)

来源:互联网 发布:淘宝电商运营方案 编辑:程序博客网 时间:2024/06/06 00:49

In BuildRoot document 3.5.2 Understanding how to rebuild packages, there are statements:

Internally, to keep track of which steps have been done andwhich steps remain to be done, Buildroot maintains stamp files (emptyfiles that just tell whether this or that action has been done):

  • output/build/<package>-<version>/.stamp_configured.If removed, Buildroot will trigger the recompilation of the package from the configuration step (execution of./configure).
  • output/build/<package>-<version>/.stamp_built. If removed, Buildroot will trigger the recompilation of the package from the compilation step (execution ofmake).
I want figure out why rm output/build/<package>-<version>/.stamp_configured, the package will recompile from the configuration step.

Look at build/package/pkg-generic.c

$(BUILD_DIR)/%/.stamp_configured:        $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))        @$(call MESSAGE,"Configuring")        $($(PKG)_CONFIGURE_CMDS)        $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))        $(Q)touch $@$(2)_TARGET_CONFIGURE =         $$($(2)_DIR)/.stamp_configured$(1)-configure:         $(1)-patch $(1)-depends \                        $$($(2)_TARGET_CONFIGURE)$(1)-build:             $(1)-configure \                        $$($(2)_TARGET_BUILD)$(1)-install-target:    $(1)-build \                        $$($(2)_TARGET_INSTALL_TARGET)$(1)-install:           $(1)-install-staging $(1)-install-target $(1)-install-images $(1):                   $(1)-install

every package/<package>/<package>.mk, there will be one statement:

 

$(eval $(autotools-package))
or

$(eval $(generic-package))

It owns dependency on each other:

if .stamp_configured file be removed, then $(1)-configure can't find its prerequisite it will call $$($(2)_TARGET_CONFIGURE)'s recipe, that is do the configure work.

if .stamp_configured file is not removed and not changed, then $(1)-configure find its prerequisite have existed, so it will not call $$($(2)_TARGET_CONFIGURE)'s recipe.

The reason why make works like this, can refer to cmake's manual 4.3 Types of prerequisite:

There are actually two different types of prerequisites understood byGNU make: normal prerequisites such as described in theprevious section, and order-only prerequisites. A normalprerequisite makes two statements: first, it imposes an order in whichrecipes will be invoked: the recipes for all prerequisites of a targetwill be completed before the recipe for the target is run. Second, itimposes a dependency relationship: if any prerequisite is newer thanthe target, then the target is considered out-of-date and must berebuilt.

that while .stamp_configured file not removed, it is same new as its target $(2)_TARGET_CONFIGURE, so not need rebuild. but if .stamp_configured file removed, it will be created and it is newer than its target $(2)_TARGET_CONFIGURE, so $$($(2)_TARGET_CONFIGURE)'s recipe will be executed.

0 0
原创粉丝点击