Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26623
  • 博文数量: 22
  • 博客积分: 25
  • 博客等级: 民兵
  • 技术积分: 125
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-24 12:40
文章分类

全部博文(22)

文章存档

2012年(22)

我的朋友
最近访客

分类:

2012-09-24 12:46:14


  1. 文章引自:http://blog.csdn.net/bsplover/article/details/4632035
刚开始我们说过,在生成配置文件有很多方法,可以使用make menuconfig也可以使用make config,那么这些实现是在makefile的什么地方:
  1. oldconfig:
            $(CONFIG_SHELL) scripts/Configure -d arch/config.in

    config:
            $(CONFIG_SHELL) scripts/Configure arch/config.in

    menuconfig: include/version.h
            $(MAKE) -C scripts/lxdialog all
            $(CONFIG_SHELL) scripts/Menuconfig arch/config.in
在scripts/目录下,有两个脚本文件:Configure与Menuconfig,他们都会载入菜单配置文件config.in,可以看到make config 与make menuconfig的不同在于,make menuconfig会进入scripts/lxdialog进行编译文件后在执行脚本,这也就是为什么在make menucofig是图形化配置而makie config 是文本化的区别了,如果对图形化的实现感兴趣,可以进入到lxdialog去看源码。

  1. // 清除目录文件,配置文件
  2. clean:
  3.       find . \( -name '*.o' -o -name core -o -name ".*.flags" \) -type f -print \
  4.       | grep -v lxdialog/ | xargs rm -f
  5.       rm -f $(CLEAN_FILES)

  6. distclean: clean
  7.       rm -f $(DISTCLEAN_FILES)
$(patsubst %, , )
函数名称:模式替换函数—patsubst。
这里的意思是把与patsubst后的第一个参数与第三个参数比较,把想匹配的参数转换成第二个参数的形式。
linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))

  1. linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))

  2. $(patsubst %, _dir_%, $(SUBDIRS)) : include/version.h
  3.        // 这里完成了目录的跳转, 跳转到子目录,执行子目录的makefile。
  4.        $(MAKE) CFLAGS="$(CFLAGS) $(CFLAGS_KERNEL)" -C $(patsubst _dir_%, %, $@)

  1. $(TOPDIR)/include/version.h: include/version.h
  2. $(TOPDIR)/include/compile.h: include/compile.h

  3. include/compile.h: $(CONFIGURATION) include/version.h
  4.      // 生成临时文件.ver,并写入信息
  5.      @echo -n \#define UTS_VERSION \"\#$(VIVIRELEASE) > .ver
  6.      @if [ -f .name ]; then echo -n \-`cat .name` >> .ver; fi
  7.      @echo ' '`date`'"' >> .ver
  8.      @echo \#define VIVI_COMPILE_TIME \"`date +%T`\" >> .ver
  9.      @echo \#define VIVI_COMPILE_BY \"`whoami`\" >> .ver
  10.      @echo \#define VIVI_COMPILE_HOST \"`hostname`\" >> .ver
  11.      @if [ -x /bin/dnsdomainname ]; then \
  12.          echo \#define VIVI_COMPILE_DOMAIN \"`dnsdomainname`\"; \
  13.      elif [ -x /bin/domainname ]; then \
  14.          echo \#define VIVI_COMPILE_DOMAIN \"`domainname`\"; \
  15.      else \
  16.          echo \#define VIVI_COMPILE_DOMAIN ; \
  17.      fi >> .ver
  18.      @echo \#define VIVI_COMPILER \"`$(CC) $(CFLAGS) -v 2>&1 | tail -1`\" >> .ver
  19.      // 修改临时文件.ver为目标文件include/compile.h
  20.      @mv -f .ver $@

  21. include/version.h:
  22.      // 生成临时文件.ver,并写入信息
  23.      @echo \#define VIVI_RELEASE \"$(VIVIRELEASE)\" > .ver
  24.      @echo \#define VIVI_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver
  25.      @echo '#define VIVI_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver
  26.      // 修改临时文件.ver为目标文件include/version.h
  27.      @mv -f .ver $@

  28. init/version.o: init/version.c include/compile.h
  29.      $(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c

  30. init/main.o: init/main.c
  31.      // "$*"这里的自动变量表示文件去掉后缀的部分,在这里”$*“表示"init/main."
  32.      // "$<"这里的自动化变量表示文件的隐含依赖规则中的第一个依赖文件,这里的”$<“表示"init/main.c"
  33.      $(CC) $(CFLAGS) $(CFLAGS_KERNEL) $(PROFILING) -c -o $*.o $<

  34. TAGS: dummy
  35.      etags `find include -name '*.h'`
  36.      find $(SUBDIRS) init -name '*.[ch]' | xargs etags -a

  37. # Exuberant ctags works better with -I
  38. tags: dummy
  39.       CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXP
  40.       ORT_SYMBOL,EXPORT_SYMBOL_NOVERS"`; \
  41.       ctags $$CTAGSF `find include -name '*.h'` && \
  42.       find $(SUBDIRS) init -name '*.[ch]' | xargs ctags $$CTAGSF -a

  43. %: ./arch/def-configs/%
  44.      $(MAKE) distclean
  45.      cp arch/def-configs/$* ./.config -f
  46.      $(MAKE) oldconfig
  47.      $(MAKE)


  48. ifdef CONFIGURATION
  49. ..$(CONFIGURATION):
  50.      @echo
  51.      @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'
  52. "
  53.       @echo
  54.       $(MAKE) $(CONFIGURATION)
  55.       @echo
  56.       @echo "Successful. Try re-making (ignore the error that follows)"
  57.       @echo
  58.       exit 1

  59. dummy:

  60. else

  61. dummy:

  62. endif

  63. include Rules.make




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