/**

******************************************************************************
* @author    Maoxiao Hu
* @version   V1.0.0
* @date       Dec-2014
******************************************************************************
* < COPYRIGHT 2014 ISE of SHANDONG UNIVERSITY >
*******************************************************************************
**/
 
Based on u-boot-2014-10.
 
当我们执行make xxx_defconfig时,顶层Makefile中唯一的匹配目标是:
 

%config: scripts_basic outputmakefile FORCE

    +$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@

 
依赖条件1:scripts_basic

scripts_basic:

    $(Q)$(MAKE) $(build)=scripts/basic

 

    $(Q)rm -f .tmp_quiet_recordmcount

 
依赖条件2:outputmakefile

outputmakefile:

ifneq ($(KBUILD_SRC),)

    $(Q)ln -fsn $(srctree) source

    $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile  

    $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)

endif

 

此时由于KBUILD_SRC为空,所以此条依赖条件并不执行。

依赖条件3:FORCE

FORCE:

执行命令:

+$(Q)$(CONFIG_SHELL) $(srctree)/scripts/multiconfig.sh $@

几个变量:

$(Q) = @  

$(CONFIG_SHELL) = /bin/sh

$(MAKE) = make

$@ = %config

$(srctree) = .

所以依赖条件1变成:

scripts_basic:

    @make $(build)=scripts/basic

    @rm -f .tmp_quiet_recordmcount

$(build)的定义在:scripts/Kbuild.include

build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj

KBUILD_SRC为空,所以$(if $(KBUILD_SRC),$(srctree)/)也为空。

所以变为:build := -f scripts/Makefile.build obj

所以依赖条件1变为:

scripts_basic:

    @make -f scripts/Makefile.build obj=scripts/basic

    @rm -f .tmp_quiet_recordmcount

此时主目标变成:

%config: scripts_basic

    +@/bin/sh ./scripts/multiconfig.sh %config

 

一、script_basic分析

scripts_basic:

    @make -f scripts/Makefile.build obj=scripts/basic

    @rm -f .tmp_quiet_recordmcount

在这里主要还是对@make -f scripts/Makefile.build obj=scripts/basic

这句命令的分析。

将obj = scripts/basic 这个变量名传入Makefile.build。

二、主目标分析

%config: scripts_basic

    +@/bin/sh ./scripts/multiconfig.sh %config

加入我们输入的命令是:make trats_defconfig

那么得到:

trats_defconfig: scripts_basic

    +@/bin/sh ./scripts/multiconfig.sh trats_defconfig

也就是将trats_defconfig这个文件传入multiconfig.sh脚本中,然后执行。

三、调用 multiconfig.sh 脚本过程分析

下面再来解析multiconfig.sh:

target=$1

 

case $target in

 

*_defconfig)

 

    do_board_defconfig $target;;

esac

 

此时target = trats_defconfig 符合*_defconfig,执行:

do_board_defconfig trats_defconfig;

do_board_defconfig是一个内部函数,另外经过替换一些已知变量后得到:

 do_board_defconfig () {
     defconfig_path=$srctree/configs/trats_defconfig
     tmp_defconfig_path=configs/.tmp_defconfig
 
     sed -n -e '/^[+A-Z]*:/!p' -e 's/^+[A-Z]*://p'$srctree/configs/trats_defconfig > configs/.tmp_defconfig
 
     run_make_config .tmp_defconfig || {
         cleanup_after_defconfig
         exit 1
     }
 
     for img in $(get_enabled_subimages)
     do
         symbol=$(echo$img| cut -c 1 | tr '[a-z]' '[A-Z]')
 
         # defconfig for SPL, TPL:
         #   pick lines with 'S', 'T' prefix and rip the prefixes off
         sed -n -e 's/^[+A-Z]*'$symbol'[A-Z]*://p'$defconfig_path > configs/.tmp_defconfig
        run_make_config .tmp_defconfig $img || {
            cleanup_after_defconfig
            exit 1
        }
    done
    cleanup_after_defconfig
}

大概意思是先把trats_defconfig复制一份到configs/.tmp_defconfig然后,

基本可以分为红色和粉红色两部分:

红色部分:

run_make_config .tmp_defconfig || {
         cleanup_after_defconfig
         exit 1
}

再次把.tmp_defconfig当作参数给run_make_config函数,run_make_config经过已知变量代换后变成:

run_make_config () {
      target=.tmp_defconfig
      objdir=
 
      options="SRCARCH=.. KCONFIG_OBJDIR="
      build scripts/kconfig SRCARCH=.. KCONFIG_OBJDIR= .tmp_defconfig
}

最后一句再次调用build函数:

 build () {
     make -f $srctree/scripts/Makefile.build obj=“$@"
}
变量代换后变成:
make -f $srctree/scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. KCONFIG_OBJDIR= .tmp_defconfig
 
粉红色部分:
     for img in $(get_enabled_subimages)
     do
         symbol=$(echo$img| cut -c 1 | tr '[a-z]' '[A-Z]')
 
         # defconfig for SPL, TPL:
         #   pick lines with 'S', 'T' prefix and rip the prefixes off
         sed -n -e 's/^[+A-Z]*'$symbol'[A-Z]*://p'$defconfig_path > configs/.tmp_defconfig
        run_make_config .tmp_defconfig $img || {
            cleanup_after_defconfig
            exit 1
        }

在这我们没有定义过SPL和TPL,所以跳过这一步。

最后,其实只有一句话:

make -f $srctree/scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. KCONFIG_OBJDIR= .tmp_defconfig

四、Makefile.build分析

从二三节得到了两条待执行的指令:

make -f scripts/Makefile.build obj=scripts/basic

make -f scripts/Makefile.build obj=scripts/kconfig SRCARCH=.. KCONFIG_OBJDIR= .tmp_defconfig

先分析第1条:

make -f scripts/Makefile.build obj=scripts/basic

编译scripts/basic.c文件

再分析第2条:

把scripts/kconfig 先传入Makefile.build中,然后再将根据其初始化的值暴露到顶层Makefile中。

匹配kconfig/Makefile里的:

%_defconfig:$(obj)/conf

    $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)

展开后:

.tmp_defconfig:scripts/kconfig/conf

    @scripts/kconfig/conf —defconfig=arch/../configs/.tmp_defconfig Kconfig

这句话的意图很明显,先编译scripts/kconfig/conf.c生成scripts/kconfig/conf,然后输入两个参数:

—defconfig=arch/../configs/.tmp_defconfig

Kconfig

五、scripts/kconfig/conf.c 解析

详见以后博客。

2014-10 u-boot make xxx_defconfig 过程分析的更多相关文章

  1. Contest - 2014 SWJTU ACM 手速测试赛(2014.10.31)

    题目列表: 2146 Problem A [手速]阔绰的Dim 2147 Problem B [手速]颓废的Dim 2148 Problem C [手速]我的滑板鞋 2149 Problem D [手 ...

  2. Linux - Eclipse CDT + GCC 安装(2014.10.2)

    Eclipse CDT + GCC 安装 (2014.10.2) 本文地址:http://blog.csdn.net/caroline_wendy 1. 安装Eclipse,在官方站点下载Eclips ...

  3. App Store审核指南中文版(2014.10.11更新)

    App Store审核指南中文版(2014.10.11更新) 2014-10-11 16:36 编辑: suiling 分类:AppStore研究 来源:CocoaChina  2 8657 App ...

  4. phpStudy + JspStudy 2014.10.02 下载

    phpStudy + JspStudy 2014.10.02 下载 目标:让天下没有难配的php环境. phpStudy Linux版&Win版同步上线 支持Apache/Nginx/Teng ...

  5. 2014.10.5 再次学习LINUX

    mesg 发送信息给root y n write/talk 写消息给 wall 给所有用户发送消息 ps -aux ps -elF pstree 命令行跳转:CTRL+a行首 CTRL+e行尾 CTR ...

  6. 【spring boot】10.spring boot下的单元测试

    spring boot下的单元测试,思前想后还是需要单独用一章篇幅来看看. 然后在看了介绍和使用时候,我感觉并不想多去看了. 但是还是给后来人留下参考的路径: 官网说明:https://spring. ...

  7. iPhone屏幕适配,历史及现状(http://hjcapple.github.io/2014/10/10/iphone-screen.html)

    iPhone屏幕适配,历史及现状 初代iPhone 2007年,初代iPhone发布,屏幕的宽高是320×480像素.下文也是按照宽度,高度的顺序排列.这个分辨率一直到iPhone 3GS的也保持不变 ...

  8. Cheatsheet: 2014 10.01 ~ 10.30

    .NET ASP.NET Web Api: Unwrapping HTTP Error Results and Model State Dictionaries Client-Side HTTP 20 ...

  9. 2014.10.09 Andrew 学习 WPF(刘铁锰) 笔记分享

    引言 主要是讲了关于WPF只是表现层的工具. 第一章: XAML : 可扩张应用程序标记语言    Extensible Application Markup Language 什么是XAML?  X ...

随机推荐

  1. iOS开发——实用篇Swift篇&保存图片到相册

    保存图片到相册 最近在深入的学习关于swift相关技术,虽然海做不出什么好的东西,但是感觉收获不少,相信总有一样能用到,所以就总结了一下,希望大家喜欢! 1.OC中的写法 在OC中,我们需要保存图片到 ...

  2. 设置用户ID和设置组ID

    与一个进程关联的ID有6个或更多,如下图所示: 与每个进程相关联的用户ID和组ID 实际用户ID 实际组ID 我们实际是谁 有效用户ID 有效组ID 附加组ID 用于文件访问权限检索 保存的设置用户I ...

  3. 十六款值得关注的NoSQL与NewSQL数据库--转载

    原文地址:http://tech.it168.com/a2014/0929/1670/000001670840_all.shtml [IT168 评论]传统关系型数据库在诞生之时并未考虑到如今如火如荼 ...

  4. 探索 Linux 内存模型--转

    引用:http://www.ibm.com/developerworks/cn/linux/l-memmod/index.html 理解 Linux 使用的内存模型是从更大程度上掌握 Linux 设计 ...

  5. 关于设置android:imeOptions属性无效的解决办法

    在对Android的EditText控件进行设置时,经常会限定一下输入法的属性,设置右下角为完成或者搜索等,一般都会想到android:imeOptions属性,但是仅仅这么设置通常是无效的,还要搭配 ...

  6. mac 下curl的使用

    curl用起来非常方便,但是老是记不住各个参数的含义,还是记录下来方便查询吧 这东西现在已经是苹果机上内置的命令行工具之一了,可见其魅力之一斑 1)二话不说,先从这里开始吧! curl http:// ...

  7. [改善Java代码]易变业务使用脚本语言编写

    建议16: 易变业务使用脚本语言编写 Java世界一直在遭受着异种语言的入侵,比如PHP.Ruby.Groovy.JavaScript等,这些“入侵者”都有一个共同特征:全是同一类语言—脚本语言,它们 ...

  8. 关于网络连接方式的总结(HostOnly,NAT....)

    真实的网络结构: 最左侧的电脑左侧的线代表,如果这台电脑有网卡的话可以去连接别的电脑. 在一台Windows中用VMware来安装一个Linux系统(用虚线的都代表不是真实的) 上图中的虚拟网关在哪里 ...

  9. 【模拟,时针分针秒针两两夹角】【没有跳坑好兴奋】hdu - 5387 (多校#8 1008)

    算是最好写的一道题了吧,最近模拟没手感,一次过也是很鸡冻o(* ̄▽ ̄*)o 注意事项都在代码里,没有跳坑也不清楚坑点在哪~ #include<cstdio> #include<cst ...

  10. hdu 4619 最大匹配问题

    思路:把所有涉及到的点按(x+y)的奇偶分成两部分点,对所有的1*2的骨牌,都有(x+y)为偶数的建到奇数的边.求一次最大匹配,就是答案. #include<iostream> #incl ...