#!/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
/*
* 循环遍历用户传递参数,根据参数设置APPEND、BOARD_NAME等相关变量值
*/
while [ $# -gt 0 ] ; do // 如果当前参数编号大于0进行循环
case "$1" in
--) shift ; break ;; //如果当前参数为"--",则将$#向下移动一位,使其指向下一个参数( 此步由shift语句完成 ),而后跳出case
-a) shift ; APPEND=yes ;; //如果当前参数为"-a", 则执行shift后,将APPEND设置为yes
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;; //如果当前参数为"-n",则执行shift后将BOARD_NAME设置为
// ${ 1%%_config }( 也就是将参数1中的"_config"去掉),再次执
// 行shift
*) break ;; //为其他选项时直接跳出
esac
done
[ "${BOARD_NAME}" ] || BOARD_NAME="$1" //如果BOARD_NAME为空,则BOARD_NAME等于第一个参数
//( [ ] 和test语句等价 )
[ $# -lt 4 ] && exit 1 //如果参数个数小于4个,则直接跳出
[ $# -gt 6 ] && exit 1 //如果参数个数大于6个,则直接跳出
echo "Configuring for ${BOARD_NAME} board..." //输出相关信息
#
# Create link to architecture specific headers
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then //判断源代码目录和目标文件目录是否一样,如果一样则进行then后语句
mkdir -p ${OBJTREE}/include //创建$( OBJTREE )/include目录 , -p 表示如果中间目录不存在,则创建它
mkdir -p ${OBJTREE}/include2 //创建$( OBJTREE )/include2目录
cd ${OBJTREE}/include2 //打开$( OBJTREE )/include2
rm -f asm // 删除该文件下的asm文件
ln -s ${SRCTREE}/include/asm-$2 asm //创建一个链接到${SRCTREE}/include/asm-$2 下的 asm链接文件 其中 $2就是传递的第二个参数
LNPREFIX="../../include2/asm/" //链接的前缀../../include2/asm/
cd ../include // 切换到目标树下创建include文件中去
rm -rf asm-$2 // 删除该文件下的asm-$2文件 其中 $2就是传递的第二个参数
rm -f asm //删除asm文件
mkdir asm-$2 //创建asm-$2文件夹
ln -s asm-$2 asm //创建一个到asm-$2文件的链接文件 asm
else //如果源代码目录和目标文件目录一致
cd ./include //打开include目录
rm -f asm //删除asm文件
ln -s asm-$2 asm //创建一个asm-$2文件的链接asm
fi //if 语句结束
rm -f asm-$2/arch //删除asm-$2/arch目录
if [ -z "$6" -o "$6" = "NULL" ] ; then //如果$6为空或者等于“NULL”,则执行then后面语句 ( -z为空,-o 为或)
ln -s ${LNPREFIX}arch-$3 asm-$2/arch //创建文件${LNPREFIX}arch-$3的连接asm-$2/arch
else //如果$6不为空或者等于"NULL"
ln -s ${LNPREFIX}arch-$6 asm-$2/arch //创建文件${LNPREFIX}arch-$6的链接asm-$2/arch
fi //结束if
if [ "$2" = "arm" ] ; then //如果$2等于"arm"
rm -f asm-$2/proc //输出asm-$2/proc文件
ln -s ${LNPREFIX}proc-armv asm-$2/proc //创建${LNPREFIX}proc-armv的链接asm-$-2/proc
fi //结束 if
#
# Create include file for Make
#
echo "ARCH = $2" > config.mk //将“ARCH = $2”输出到config.mk文件中
echo "CPU = $3" >> config.mk //将"CPU = $3"输出到config.mk文件中
echo "BOARD = $4" >> config.mk //将"BOARD=$4"输出到config.mk文件中
[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk //如果$5不为空且不等于NULL,将"VENDOR=$5"输出到config.mk文件中
[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk //如果$6不为空且不等于NULL,将"SOC=$6"输出到config.mk文件中
#
# Create board specific header file
#
if [ "$APPEND" = "yes" ] # Append to existing config file //如果APPEND等于yes
then
echo >> config.h //在config.h尾追加一行空格
else
> config.h # Create new config file //创建一个新的config.h文件
fi //结束if
echo "/* Automatically generated - do not edit */" >>config.h //向config.h文件输入 /* Automatically generated - do not edit */
echo "#include <configs/$1.h>" >>config.h //向config.h文件中输入#include< configs/$1.h>
exit 0 //程序退出
http://blog.csdn.net/heaiding/article/details/6103937