#!/bin/sh -e
#mkconfig 100ask24x0 arm arm920t 100ask24x0 Null s3c24x0
#s0 s1 s2 s3 s4 s5 s6
# 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 $#表示输入进来的参数个数,-gt(greatthan)表示左边大于右边则返回真
case "$1" in
--) shift ; break ;;
-a) shift ; APPEND=yes ;;
-n) shift ; BOARD_NAME="${1%%_config}" ; shift ;;
*) break ;;
esac
done mkconfig没有这些参数,所以上面语句不执行
[ "${BOARD_NAME}" ] || BOARD_NAME="$1" 此处很重要,他给BOARD_NAME赋值为$1,即100ask24x0
[ $# -lt 4 ] && exit 1 $#表示数目参数 lt是小于的意思,-le是小于等于的意思,此处用于判断参数的个数是否符合要求
[ $# -gt 6 ] && exit 1 @执行这两个数表示如果参数小于4或者大于6,退出
echo "Configuring for ${BOARD_NAME} board..." 不退出,符合,打印出这一行
#
# Create link to architecture specific headers
#
if [ "$SRCTREE" != "$OBJTREE" ] ; then 判断是不是目标文件和源文件一致,可以选择在别的文件建立编译过程,显然不成立,执行else
OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
SRCTREE := $(CURDIR)
mkdir -p ${OBJTREE}/include
mkdir -p ${OBJTREE}/include2
cd ${OBJTREE}/include2
rm -f asm 删除上次配置产生的链接文件
ln -s ${SRCTREE}/include/asm-$2 asm 再次建立链接文件,并让它指向asm-$2,即asm-->asm-arm
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 再次建立链接文件,并让它指向asm-$2,即asm-->asm-arm 配置时临时生成
fi
rm -f asm-$2/arch 删除asm-$2/arch,即asm-arm/arch
if [ -z "$6" -o "$6" = "NULL" ] ; then 判断$6是否为空,或等于NULL,此处为假,所以执行else
ln -s ${LNPREFIX}arch-$3 asm-$2/arch
else
ln -s ${LNPREFIX}arch-$6 asm-$2/arch 相当于ln -s arch-s3c24x0 asm-asm/arch 链接文件arch指向arch-s3c24x0
fi
if [ "$2" = "arm" ] ; then 如果$2=arm,则执行以下步骤
rm -f asm-$2/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc 建立链接文件 ln -s proc-armv asm-arm/proc 链接文件proc指向proc-armv
fi
#
# Create include file for Make 生成一个配置文件
#
echo "ARCH = $2" > config.mk >表示新建一个文件,>>追加,把内容追加过去
echo "CPU = $3" >> config.mk
echo "BOARD = $4" >> config.mk
执行完之后,config.mk的内容为
ARCH =arm
CP = arm920t
BOARD = 100ask24x0
SOC = s3c24x0
[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk
创建顶层包含的include/config.mk文件。其内容很简单。
此处>是重定向,>>也是重定向,只是追加在文件尾部。
往config.mk里面写入:ARCH=arm,CPU=arm920t,BOARD=ask24x0,SOC=s3c24x0
你可以在顶层目录输入makesmdk2410_config,在include目录里面多了一个config.mk文件,
里面内容就是刚刚写入的内容
#
# Create board specific header file 创建一个单板相关的头文件
#
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
config.h的内容是:
/* Automatically generated - do not edit */
#include <configs/100ask24x0.h>
exit 0