1 整体执行流程
make tools/xxx/compile和make package/xxx/compile相似。
都是先执行
%::
make prereq
make $@ ->make tools/xxx/compile
### 1.1 make prereq
和make package/xxx/compile相同make tools/xxx/compile下的make prereq流程如下。
prereq整理后的依赖关系如下图:
其中prepare-tmpinfo=$(TOPDIR)/tmp/.build
其差异之处在于make tools/xxx/compile时Makefile调用的是HostBuild而不是PackgeBuild。
1.2 make $@ ->make tools/xxx/compile
和package不同,tool编译时compile目标在tools/Makefile直接定义。最终通过调用定义在host-build.mk定义的HostBuild函数编译对应tools,其定义如下
HostBuild的定义在host-build.mk中,可以看到HostBuild调用HostBuildCore
define HostBuild
$(HostBuild/Core)
$(if $(if $(PKG_HOST_ONLY),,$(STAMP_PREPARED)),,$(if $(strip $(PKG_SOURCE_URL)),$(call Download,default)))
endef
HostBuild/Core同样定义在host-build.mk中,
$(HOST_STAMP_PREPARED):解压目的工具压缩包并打patch。
$(HOST_STAMP_CONFIGURED):拷贝配置文件,编译参数等,运行configure生成Makefile
$(HOST_STAMP_BUILT):执行工具目录下生成的makefile。
$(HOST_STAMP_INSTALLED):将编译后的工具拷贝到staging_dir目录下。
ifndef DUMP
define HostBuild/Core
$(if $(HOST_QUILT),$(Host/Quilt))
$(if $(DUMP),,$(call HostHost/Autoclean))
$(HOST_STAMP_PREPARED):
@-rm -rf $(HOST_BUILD_DIR)
@mkdir -p $(HOST_BUILD_DIR)
$(foreach hook,$(Hooks/HostPrepare/Pre),$(call $(hook))$(sep))
$(call Host/Prepare)
$(foreach hook,$(Hooks/HostPrepare/Post),$(call $(hook))$(sep))
touch $$@
$(call Host/Exports,$(HOST_STAMP_CONFIGURED))
$(HOST_STAMP_CONFIGURED): $(HOST_STAMP_PREPARED)
$(foreach hook,$(Hooks/HostConfigure/Pre),$(call $(hook))$(sep))
$(call Host/Configure)
$(foreach hook,$(Hooks/HostConfigure/Post),$(call $(hook))$(sep))
touch $$@
$(call Host/Exports,$(HOST_STAMP_BUILT))
$(HOST_STAMP_BUILT): $(HOST_STAMP_CONFIGURED)
$(foreach hook,$(Hooks/HostCompile/Pre),$(call $(hook))$(sep))
$(call Host/Compile)
$(foreach hook,$(Hooks/HostCompile/Post),$(call $(hook))$(sep))
touch $$@
$(call Host/Exports,$(HOST_STAMP_INSTALLED))
$(HOST_STAMP_INSTALLED): $(HOST_STAMP_BUILT) $(if $(FORCE_HOST_INSTALL),FORCE)
$(call Host/Install,$(HOST_BUILD_PREFIX))
$(foreach hook,$(Hooks/HostInstall/Post),$(call $(hook))$(sep))
mkdir -p $$(shell dirname $$@)
touch $(HOST_STAMP_BUILT)
touch $$@
$(call DefaultTargets,$(patsubst %,host-%,$(DEFAULT_SUBDIR_TARGETS)))
ifndef STAMP_BUILT
$(foreach t,$(DEFAULT_SUBDIR_TARGETS),
$(t): host-$(t)
.$(t): .host-$(t)
)
clean-build: host-clean-build
endif
$(DL_DIR)/$(FILE): FORCE
$(_host_target)host-prepare: $(HOST_STAMP_PREPARED)
$(_host_target)host-configure: $(HOST_STAMP_CONFIGURED)
$(_host_target)host-compile: $(HOST_STAMP_BUILT) $(HOST_STAMP_INSTALLED)
host-install: host-compile
host-clean-build: FORCE
$(call Host/Uninstall)
rm -rf $(HOST_BUILD_DIR) $(HOST_STAMP_BUILT)
host-clean: host-clean-build
$(call Host/Clean)
rm -rf $(HOST_STAMP_INSTALLED)
ifneq ($(CONFIG_AUTOREMOVE),)
host-compile:
$(FIND) $(HOST_BUILD_DIR) -mindepth 1 -maxdepth 1 -not '(' -type f -and -name '.*' -and -size 0 ')' | \
$(XARGS) rm -rf
endif
endef
endif
当前一个tools的编译流程就完成了。