uboot顶层mkconfig分析

GNU make:http://www.gnu.org/software/make/manual/make.html#Rules

为了便于理解把uboot中的Makefile配置部分弄出来便于理解,这里贴出我的Makefile配置部分。我的是FREESCALE的mx6q_sabresd开发板

mx6solo_sabresd_config \
mx6solo_sabresd_mfg_config \
mx6solo_sabresd_android_config \
mx6dl_sabresd_config \
mx6dl_sabresd_mfg_config \
mx6dl_sabresd_android_1G_config \
mx6dl_sabresd_android_2G_config \
mx6q_sabresd_config \
mx6q_sabresd_android_1G_config \
mx6q_sabresd_android_2G_config \
mx6q_sabresd_mfg_config \
mx6q_sabresd_iram_config : unconfig
@[ -z "$(findstring iram_,$@)" ] || \
{ echo "TEXT_BASE = 0x00907000" >$(obj)board/freescale/mx6q_sabresd/config.tmp ; \
echo "... with iram configuration" ; \
}
@$(MKCONFIG) $(@:_config=) arm arm_cortexa8 mx6q_sabresd freescale mx6//$(@:_config=)在做什么很了解,其实它就是将$@即目标

smdk2410_config的后面的_config替换成空

@@@@@@@@@@@@@@@@@   $1        $2                    $3                 $4          $5

 整个mkconfig的作用如下

     (1).   BOARD_NAME='mx6q_sabresd'
        (2).   ln -s asm-arm asm
                 ln -s arch-mx6 asm-arm/arch
                 ln -s proc-armv asm-arm/proc
        (3).   创建include/config.mk
        (4).   创建include/config.h

#!/bin/sh -e

# Script to create header files and links to configure
# U-Boot for a specific board.
#
# Parameters: Target Architecture CPU Board [VENDOR] [SOC]
#
# (C) 2002-2006 DENX Software Engineering, Wolfgang Denk <[email protected]>
#

APPEND=no # Default: Create new config file
BOARD_NAME="" # Name to print in make output

while [ $# -gt 0 ] ; do
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
*) break ;;
esac
done

[ "${BOARD_NAME}" ] || BOARD_NAME="$1"

[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1

echo "Configuring for ${BOARD_NAME} board..."

#
# Create link to architecture specific headers

#创建到平台,开发板相关的头文件的链接
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then
mkdir -p ${OBJTREE}/include    //。mkdir的-p选项允许你一次性创建多层次的目录,而不是一次只创建单独的目录。例如,我们要在当前目录创建目录Projects/a/src,使用命令
mkdir -p ${OBJTREE}/include2
cd ${OBJTREE}/include2  
rm -f asm
ln -s ${SRCTREE}/include/asm-$2 asm
LNPREFIX="../../include2/asm/"
cd ../include     //这条语句决定了下面所以的config.mk 以及config.h都是在/include这个文件夹下定义的
rm -rf asm-$2
rm -f asm
mkdir asm-$2
ln -s asm-$2 asm
else
cd ./include
rm -f asm
ln -s asm-$2 asm
fi

rm -f asm-$2/arch

if [ -z "$6" -o "$6" = "NULL" ] ; then
ln -s ${LNPREFIX}arch-$3 asm-$2/arch
else
ln -s ${LNPREFIX}arch-$6 asm-$2/arch
fi

if [ "$2" = "arm" ] ; then
rm -f asm-$2/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi

#
# Create include file for Make

#cd ../include     //这条语句决定了下面所以的config.mk 以及config.h都是在/include这个文件夹下定义的
#
echo "ARCH = $2" > config.mk
echo "CPU = $3" >> config.mk
echo "BOARD = $4" >> config.mk

[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk //此处的 [此中的内容相当于测试是否为空]

[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk

/********************

 

***这几句很简单,就是创建config.mk,请注意,之前46行我们就已经在include目录下面了,因此这几行执行完成后,config.mk的内容就应该是下面的样子:

1 ARCH = arm
2 CPU = arm_cortexa8
3 BOARD = mx6q_sabresd
4 VENDOR = freescale
5 SOC = mx6

 

***********************/

 

#
# Create board specific header file

#最后就开始创建include/config.h:
#
if [ "$APPEND" = "yes" ] # Append to existing config file
then
echo >> config.h
else
> config.h # Create new config file
fi
echo "/* Automatically generated - do not edit */" >>config.h
echo "#include <configs/$1.h>" >>config.h
echo "#include <asm/config.h>" >>config.h

exit 0

/**********************

在这里我打开config.h给各位看下,我的是针对mx6q_sabresd开发板

1 /* Automatically generated - do not edit */
2 #include <configs/mx6q_sabresd_android_2G.h>
3 #include <asm/config.h>

***********************/

你可能感兴趣的:(config)