Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15490647
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2011-04-08 09:51:16

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

其中
/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 -f /home/gliethttp/kernel/Makefile silentoldconfig
  3. make -f scripts/Makefile.build obj=scripts/basic
  4.   gcc -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.c
  5.   gcc -Wp,-MD,scripts/basic/.docproc.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/docproc scripts/basic/docproc.c
  6.   gcc -Wp,-MD,scripts/basic/.hash.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/hash scripts/basic/hash.c
  7. mkdir -p 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. }}}


阅读(4995) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~