码迷,mamicode.com
首页 > 其他好文 > 详细

mkconfig分析

时间:2015-07-08 14:24:17      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:

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替换成空

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

 整个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 <wd@denx.de>
#

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
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
#
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>

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

mkconfig分析

标签:

原文地址:http://www.cnblogs.com/haoxing990/p/4629960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!