如何让include/config/auto.conf超越终极目标的

http://blog.chinaunix.net/uid-20564848-id-215793.html

其中
/gliethttp.ini是一个存在的空文件
/gliethttp/auto.conf不存在
我们可以看到,如果-include的文件不存在,首先不会报错,
其次如果在整个makefile中如果发现有创建该文件的规则,那么会在终极目标(第1个目标)
执行之前,首先尝试执行创建该-include文件的目标,
所以这时该文件目标就先于终极目标被make执行[luther.gliethttp]
  1. {{{
  2. all:
  3.     @echo 111
  4. -include /gliethttp/auto.conf
  5. /gliethttp/auto.conf:
  6.     @echo 222
  7. -include /gliethttp.ini
  8. /gliethttp.ini:
  9.     @echo 333
  10. }}}

luther@gliethttp:~$ make
222
111


来看看kernel的Makefile片段,
当我们执行make时,首先Makefile被make走一遍,提取规则和变量等,
如果是第1次执行,那么include/config/auto.conf并不存在,
所以我们看到
make -f /home/gliethttp/kernel/Makefile silentoldconfig
是第1条被执行的规则命令

luther@gliethttp:~/kernel$ make V=1
  1. {{{
  2. make -/home/gliethttp/kernel/Makefile silentoldconfig
  3. make -f scripts/Makefile.build obj=scripts/basic
  4.   gcc -Wp,-MD,scripts/basic/.fixdep.-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.
  5.   gcc -Wp,-MD,scripts/basic/.docproc.-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/docproc scripts/basic/docproc.
  6.   gcc -Wp,-MD,scripts/basic/.hash.-Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/hash scripts/basic/hash.
  7. mkdir -include/linux include/config
  8. make -f scripts/Makefile.build obj=scripts/kconfig silentoldconfig
  9. }}}

如下是kernel的Makefile片段内容
  1. {{{
  2. # Read in config
  3. -include include/config/auto.conf

  4. ifeq ($(KBUILD_EXTMOD),)
  5. # Read in dependencies to all Kconfig* files, make sure to run
  6. # oldconfig if changes are detected.
  7. -include include/config/auto.conf.cmd

  8. # To avoid any implicit rule to kick in, define an empty command
  9. $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;

  10. # If .config is newer than include/config/auto.conf, someone tinkered
  11. # with it and forgot to run make oldconfig.
  12. # if auto.conf.cmd is missing then we are probably in a cleaned tree so
  13. # we execute the config step to be sure to catch updated Kconfig files
  14. include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
  15.     $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
  16. }}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值