201106rc3uboot的mkconfig注释

201106rc3uboot的mkconfig注释

#make smdk2410_config 在Makefile中实际调用了$(CURDIR)/mkconfig -A smdk2410
#两个参数 $1为-A $2为smdk2410

#!/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-2010 DENX Software Engineering, Wolfgang Denk <[email protected]>
#

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

arch=""
cpu=""
board=""
vendor=""
soc=""
options=""
#参数数量==2 并且 参数1==-A 所以make smdk2410_config进入
if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then
 # Automatic mode
 #在boards.cfg不区分大小写,查找smdk2410开头的行,赋值给line
 #line==smdk2410 arm arm920t - samsung s3c24x0
 line=`egrep -i "^[[:space:]]*${2}[[:space:]]" boards.cfg` || {
  echo "make: *** No rule to make target \`$2_config''.  Stop." >&2
  exit 1
 }
 #设置$1=smdk2410 $2=arm $3=arm920t $4=- $5=samsung $6=s3c24x0 and $#=6
 set ${line}
 # add default board name if needed
 #[ $# = 3 ]不成立,不执行set ${line} ${1}
 [ $# = 3 ] && set ${line} ${1}
fi
#$#=6>0,进入循环 实际上命令make smdk2410_config变成$(CURDIR)/mkconfig smdk2410 arm arm920t - samsung s3c24x0
#$1=smdk2410 所以直接break
while [ $# -gt 0 ] ; do
 case "$1" in
 --) shift ; break ;;
 -a) shift ; APPEND=yes ;;
 -n) shift ; BOARD_NAME="${1%_config}" ; shift ;;
 -t) shift ; TARGETS="`echo $1 | sed ''s:_: :g''` ${TARGETS}" ; shift ;;
 *)  break ;;
 esac
done
#以下两行都不成立,不退出
[ $# -lt 4 ] && exit 1
[ $# -gt 7 ] && exit 1

# Strip all options and/or _config suffixes
#smdk2410没有匹配_config的字符串,不用去掉,所以CONFIG_NAME="smdk2410"
CONFIG_NAME="${1%_config}"
#BOARD_NAME="smdk2410"
[ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
#arch="arm"
arch="$2"
#cpu="arm920t"
cpu="$3"
#board="smdk2410"
if [ "$4" = "-" ] ; then
 board=${BOARD_NAME}
else
 board="$4"
fi
#vendor="samsung"
[ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5"
#soc="s3c24x0"
[ $# -gt 5 ] && [ "$6" != "-" ] && soc="$6"
#[ $# -gt 6 ]不成立,不运行下面的
[ $# -gt 6 ] && [ "$7" != "-" ] && {
 # check if we have a board config name in the options field
 # the options field mave have a board config name and a list
 # of options, both separated by a colon ('':''); the options are
 # separated by commas ('','').
 #
 # Check for board name
 tmp="${7%:*}"
 if [ "$tmp" ] ; then
  CONFIG_NAME="$tmp"
 fi
 # Check if we only have a colon...
 if [ "${tmp}" != "$7" ] ; then
  options=${7#*:}
  TARGETS="`echo ${options} | sed ''s:,: :g''` ${TARGETS}"
 fi
}
#${ARCH}不存在,不进入
if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then
 echo "Failed: \$ARCH=${ARCH}, should be ''${arch}'' for ${BOARD_NAME}" 1>&2
 exit 1
fi
#options为空,不进入,echo "Configuring for smdk2410 board..."
if [ "$options" ] ; then
 echo "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}"
else
 echo "Configuring for ${BOARD_NAME} board..."
fi

#
# Create link to architecture specific headers
#
#因为没有加入 O= ,所以$SRCTREE=$OBJTREE=$(CURDIR)  $(CURDIR)是GNU MAKE的环境变量,值为当前文件夹绝对路径
if [ "$SRCTREE" != "$OBJTREE" ] ; then
 mkdir -p ${OBJTREE}/include
 mkdir -p ${OBJTREE}/include2
 cd ${OBJTREE}/include2
 rm -f asm
 ln -s ${SRCTREE}/arch/${arch}/include/asm asm
 LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/
 cd ../include
 mkdir -p asm
else
 #连接到目标平台的include/asm目录
 cd ./include
 rm -f asm #删除上次编译产生的asm软连接
 ln -s ../arch/${arch}/include/asm asm
fi
#删除上次编译产生的asm/arch软连接
rm -f asm/arch
#${soc}="s3c24x0" 不为null,不进入
if [ -z "${soc}" ] ; then
 ln -s ${LNPREFIX}arch-${cpu} asm/arch
else
 #建立软连接include/asm/arch,连接到 arch/arm/include/asm/arch-s3c24x0  ${LNPREFIX}为空 注意连接的目标所在目录
 ln -s ${LNPREFIX}arch-${soc} asm/arch
fi
#进入
if [ "${arch}" = "arm" ] ; then
 #删除上次编译产生的asm/proc软连接
 rm -f asm/proc
 #建立软连接include/asm/proc,连接到 arch/arm/include/asm/proc-armv
 ln -s ${LNPREFIX}proc-armv asm/proc
fi

#
# Create include file for Make
#
#在include/config.mk文件中加入5个变量
echo "ARCH   = ${arch}"  >  config.mk
echo "CPU    = ${cpu}"   >> config.mk
echo "BOARD  = ${board}" >> config.mk

[ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk

[ "${soc}"    ] && echo "SOC    = ${soc}"    >> config.mk

# Assign board directory to BOARDIR variable
#${vendor}不为null,不进入
if [ -z "${vendor}" ] ; then
    BOARDDIR=${board}
else
 #BOARDDIR=samsung/smdk2410
    BOARDDIR=${vendor}/${board}
fi

#
# Create board specific header file
#
//$APPEND = no ,不进入
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
#${TARGETS}为空,for循环没执行
for i in ${TARGETS} ; do
 i="`echo ${i} | sed ''/=/ {s/=/\t/;q } ; { s/$/\t1/ }''`"
 echo "#define CONFIG_${i}" >>config.h ;
done
#cat追加内容进config.h
cat << EOF >> config.h
#define CONFIG_BOARDDIR board/$BOARDDIR
#include
#include
#include
#include
EOF

exit 0

你可能感兴趣的:(201106rc3uboot的mkconfig注释)