2014-10 u-boot 顶层config.mk分析

/**
******************************************************************************
* @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

其它编译选项就不做解释了。
上一篇:Itextsharp下根据Echarts图像生成pdf


下一篇:Beta 第一天