MT7688 openwrt makefile 主要流程

42 篇文章 2 订阅
11 篇文章 2 订阅

1.  openwrt_widora/Makefile

   world:                      主目标


   include $(TOPDIR)/include/host.mk


ifneq ($(OPENWRT_BUILD),1)                       //第一次运行 
  _SINGLE=export MAKEFLAGS=$(space);


  override OPENWRT_BUILD=1
  export OPENWRT_BUILD
  GREP_OPTIONS=
  export GREP_OPTIONS
  include $(TOPDIR)/include/debug.mk
  include $(TOPDIR)/include/depends.mk
  include $(TOPDIR)/include/toplevel.mk
else                                                         // OPENWRT_BUILD = 1,第一次运行以后执行下面
  include rules.mk
  include $(INCLUDE_DIR)/depends.mk
  include $(INCLUDE_DIR)/subdir.mk
  include target/Makefile
  include package/Makefile
  include tools/Makefile

  include toolchain/Makefile

在这里引入了

include target/Makefile include package/Makefile include tools/Makefile include toolchain/Makefile

这些子目录里的Makefile使用include/subdir.mk里定义的两个函数来动态生成规则,这两个函数是subdir和stampfile

 拿target/Makefile举例:

(eval(call stampfile,$(curdir),target,prereq,.config))

会生成规则:

target/stamp-prereq:=$(STAGING_DIR)/stamp/.target_prereq 
$$(target/stamp-prereq): $(TMP_DIR)/.build .config 
	@+$(SCRIPT_DIR)/timestamp.pl -n $$(target/stamp-prereq) target .config || \
		make $$(target/flags-prereq) target/prereq 
	@mkdir -p $$$$(dirname $$(target/stamp-prereq)) 
	@touch $$(target/stamp-prereq) 
$$(if $(call debug,target,v),,.SILENT: $$(target/stamp-prereq))
.PRECIOUS: $$(target/stamp-prereq) # work around a make bug

target//clean:=target/stamp-prereq/clean 
target/stamp-prereq/clean: FORCE 
	@rm -f $$(target/stamp-prereq)

 拿target/Makefile举例:

(eval(call stampfile,$(curdir),target,prereq,.config))

会生成规则:

target/stamp-prereq:=$(STAGING_DIR)/stamp/.target_prereq 
$$(target/stamp-prereq): $(TMP_DIR)/.build .config 
	@+$(SCRIPT_DIR)/timestamp.pl -n $$(target/stamp-prereq) target .config || \
		make $$(target/flags-prereq) target/prereq 
	@mkdir -p $$$$(dirname $$(target/stamp-prereq)) 
	@touch $$(target/stamp-prereq) 
$$(if $(call debug,target,v),,.SILENT: $$(target/stamp-prereq))
.PRECIOUS: $$(target/stamp-prereq) # work around a make bug

target//clean:=target/stamp-prereq/clean 
target/stamp-prereq/clean: FORCE 
	@rm -f $$(target/stamp-prereq)

所以可以简单的看作: (eval(call stampfile,(curdir),target,prereq,.config))生成了目标(target/stamp-prereq)

  • 对于target分别生成了:(target/stamp-preq),(target/stamp-copile), $(target/stamp-install)
  • toolchain : $(toolchain/stamp-install)
  • package : (package/stamp?preq),(package/stamp-cleanup), (package/stamp?compile),(package/stamp-install)
  • tools : $(tools/stamp-install)

OpenWrt的主Makefile工作过程

subdir

subdir这个函数写了一大堆东西,看起来很复杂 。

$(call subdir, target) 会遍历下的子目录,执行 make -C 操作。这样就切入子目录中去了







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值