/**

******************************************************************************
* @author    Maoxiao Hu
* @version   V1.0.0
* @date       Dec-2014
******************************************************************************
* < COPYRIGHT 2014 ISE of SHANDONG UNIVERSITY >
*******************************************************************************
**/
 
Based on u-boot-2014-10.
顶层config.mk的内容并不长,这里全部贴出来吧。
这里以已经执行完make trats_defconfig(这个流程可以参看:《2014-10 u-boot make xxx_defconfig 过程分析》),在顶层目录已经生成了.config文件为例,说明config.mk中各变量的取值。
 

 15 PLATFORM_RELFLAGS :=

 16 PLATFORM_CPPFLAGS :=

 17 PLATFORM_LDFLAGS :=

 18 LDFLAGS :=

 19 LDFLAGS_FINAL :=

 20 OBJCOPYFLAGS :=

 21 #########################################################################

 22 

 23 ARCH := $(CONFIG_SYS_ARCH:"%"=%)

 24 CPU := $(CONFIG_SYS_CPU:"%"=%)

 25 BOARD := $(CONFIG_SYS_BOARD:"%"=%)

 26 ifneq ($(CONFIG_SYS_VENDOR),)

 27 VENDOR := $(CONFIG_SYS_VENDOR:"%"=%)

 28 endif

 29 ifneq ($(CONFIG_SYS_SOC),)

 30 SOC := $(CONFIG_SYS_SOC:"%"=%)

 31 endif

 32 

 33 # Some architecture config.mk files need to know what CPUDIR is set to,

 34 # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.

 35 # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains

 36 # CPU-specific code.

 37 CPUDIR=arch/$(ARCH)/cpu$(if $(CPU),/$(CPU),)

 38 

 39 sinclude$(srctree)/arch/$(ARCH)/config.mk  # include architecture dependend rules

 40 sinclude$(srctree)/$(CPUDIR)/config.mk     # include  CPU  specific rules

 41 

 42 ifdef   SOC

 43 sinclude$(srctree)/$(CPUDIR)/$(SOC)/config.mk  # include  SoC  specific rules

 44 endif

 45 ifneq ($(BOARD),)

 46 ifdef   VENDOR

 47 BOARDDIR = $(VENDOR)/$(BOARD)

 48 else

 49 BOARDDIR = $(BOARD)

 50 endif

 51 endif

 52 ifdef   BOARD

 53 sinclude$(srctree)/board/$(BOARDDIR)/config.mk # include board specific rules

 54 endif

 55 

 56 ifdef FTRACE

 57 PLATFORM_CPPFLAGS += -finstrument-functions -DFTRACE

 58 endif

 59 

 60 #########################################################################

 61 

 62 RELFLAGS := $(PLATFORM_RELFLAGS)

 63 

 64 OBJCOPYFLAGS += --gap-fill=0xff

 65 

 66 PLATFORM_CPPFLAGS += $(RELFLAGS)

 67 PLATFORM_CPPFLAGS += -pipe

 68 

 69 LDFLAGS += $(PLATFORM_LDFLAGS)

 70 LDFLAGS_FINAL += -Bstatic

 71 

 72 export PLATFORM_CPPFLAGS

 73 export RELFLAGS

 74 export LDFLAGS_FINAL

 75 export CONFIG_STANDALONE_LOAD_ADDR

 
 
config.mk被顶层Makefile包含,通过:

include$(srctree)/config.mk

这句话。
 
ARCH := $(CONFIG_SYS_ARCH:"%"=%)
ARCH = “arm”
CPU := $(CONFIG_SYS_CPU:"%"=%)
CPU = “armv7”
BOARD := $(CONFIG_SYS_BOARD:"%"=%)
BOARD = “trats”
 

ifneq ($(CONFIG_SYS_VENDOR),)

 VENDOR := $(CONFIG_SYS_VENDOR:"%"=%)

endif

在这里CONFIG_SYS_VENDOR = “samsung” 所以 VENDOR = “samsung”
 

ifneq ($(CONFIG_SYS_SOC),)

SOC := $(CONFIG_SYS_SOC:"%"=%)

endif

在这里CONFIG_SYS_SOC = “exynos” 所以 SOC = “exynos”
 
CPUDIR=arch/$(ARCH)/cpu$(if $(CPU),/$(CPU),)
替换已知变量:
CPUDIR=arch/arm/cpu/armv7
 

sinclude$(srctree)/arch/$(ARCH)/config.mk  # include architecture dependend rules

sinclude$(srctree)/$(CPUDIR)/config.mk     # include  CPU  specific rules

替换已知变量:

sinclude$(srctree)/arch/arm/config.mk  # include architecture dependend rules

sinclude$(srctree)/arch/arm/cpu/armv7/config.mk     # include  CPU  specific rules

 
 

 42 ifdef   SOC

 43 sinclude$(srctree)/$(CPUDIR)/$(SOC)/config.mk  # include  SoC  specific rules

 44 endif

已定义SOC,替换已知变量:

 43 sinclude$(srctree)/arch/arm/cpu/armv7/exynos/config.mk  # include  SoC  specific rules

 

 45 ifneq ($(BOARD),)

 46 ifdef   VENDOR

 47 BOARDDIR = $(VENDOR)/$(BOARD)

 48 else

 49 BOARDDIR = $(BOARD)

 50 endif

 51 endif

BOARD变量不为空,且已定义VENDOR,替换已知变量:

 47 BOARDDIR = samsung/trats

 

 52 ifdef   BOARD

 53 sinclude$(srctree)/board/$(BOARDDIR)/config.mk # include board specific rules

 54 endif

已定义BOARD,替换已知变量:

 53 sinclude$(srctree)/board/samsung/trats/config.mk # include board specific rules

 
总结,源文件经过替换后,变成下面代码:
ARCH = “arm”
CPU = “armv7”
BOARD = “trats”
VENDOR = “samsung”
SOC = “exynos”
CPUDIR=arch/arm/cpu/armv7

sinclude$(srctree)/arch/arm/config.mk  # include architecture dependend rules

sinclude$(srctree)/arch/arm/cpu/armv7/config.mk     # include  CPU  specific rules

sinclude$(srctree)/arch/arm/cpu/armv7/exynos/config.mk  # include  SoC  specific rules

BOARDDIR = samsung/trats

sinclude$(srctree)/board/samsung/trats/config.mk # include board specific rules

其它编译选项就不做解释了。

2014-10 u-boot 顶层config.mk分析的更多相关文章

  1. uboot顶层config.mk分析

    uboot顶层目录中的config.mk定义了确定了当前执行makefile所对应的源文件目录.目标文件目录,编译的程序编译.连接的选项,以及目标文件生成的规则等等.它被包含在顶层的makefile以 ...

  2. u-boot顶层目录config.mk分析

    1. 设置obj与src ifneq ($(OBJTREE),$(SRCTREE)) ifeq ($(CURDIR),$(SRCTREE)) dir := else dir := $(subst $( ...

  3. uboot总结:uboot配置和启动过程3(config.mk分析)

    说明:文件位置:在uboot的目录下,文件名为:config.mk.是一个makefile文件,以后会被主Makefile调用. 它的主要作用的是: (1)具体的设置交叉编译工具链接(主Makefil ...

  4. U-Boot Makefile分析(2) config.mk分析

    浏览一下U-Boot各个子目录下的Makefile可以看到,几乎他们都会包含$(TOPDIR)/config.mk,那么这个文件进行了什么操作呢?简单概括:读入include/config.mk.in ...

  5. U-Boot Makefile分析(3) rules.mk分析

    浏览各个子Makefile可以发现,他们都会在文件的后面包含rules.mk,这个文件的作用就是更新源文件的依赖,并生成各种.depend文件. _depend: $(obj).depend # Sp ...

  6. uboot 顶层makefile细节分析

    uboot的源文件众多,学习庞然大物首先找到脊椎--顶层的makfile,逐一破解.但是,uboot的makefile同样是一个庞然大物,所以也要找到它的主线.倘若过分专注部分细节,很难做到把握全局, ...

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

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

  8. Spring Boot 实战与原理分析视频课程

    Spring Boot 实战与原理分析视频课程 链接:https://pan.baidu.com/share/init?surl=PeykcoeqZtd1d9lN9V_F-A 提取码: 关注公众号[G ...

  9. spring boot启动原理步骤分析

    spring boot最重要的三个文件:1.启动类 2.pom.xml 3.application.yml配置文件 一.启动类->main方法 spring boot启动原理步骤分析 1.spr ...

随机推荐

  1. curl要注意的几点

    1.post提交数据 $postData = array( 'paramCity' => array(array('id' => $city_id, 'day' => $city_d ...

  2. Key Task

    Problem Description The Czech Technical University is rather old - you already know that it celebrat ...

  3. qsort函数、sort函数 (精心整理篇)

    先说明一下qsort和sort,只能对连续内存的数据进行排序,像链表这样的结构是无法排序的. 首先说一下, qsort qsort(基本快速排序的方法,每次把数组分成两部分和中间的一个划分值,而对于有 ...

  4. focusky 购买指南

    升级Focusky动画演示大师 所有版本一次购买,终身使用,无限制作,免费升级.支付方式:支付宝.淘宝.银行转账.支付宝付款:点击表格中的“立即购买“进入购买页面->选择版本.数量,并填写详细的 ...

  5. apache 配置order allow deny讲解

    http://www.111cn.net/phper/apache/43025.htm

  6. linux的rpm命令

    rpm 执行安装包二进制包(Binary)以及源代码包(Source)两种.二进制包可以直接安装在计算机中,而源代码包将会由 RPM自动编译.安装.源代码包经常以src.rpm作为后缀名. 常用命令组 ...

  7. Partitioning, Shuffle and sort

    Partitioning, Shuffle and sort  what happened? - Partitioning Partitioning is the process of determi ...

  8. 自定义JPA之AttributeConverter

    1. 执行类 public class BooleanConverter implements AttributeConverter<Boolean, Integer> { } 2. 属性 ...

  9. 为MYPoint类写一个分类

    #import <Foundation/Foundation.h> //xieyi @protocol showOn @required -(void)printOn; @end // l ...

  10. Linux 下安装配置nginx及常见问题解答

    其实也不能完全算是原创吧!都是我配置nginx时所遇到的问题,查阅资料后总结起来.即是巩固一下nginx的配置,也是分享给新入Linux的童鞋们一些知识 好了,不多废话,进入主题吧! 为nginx添加 ...