###############################################
#命令行参数 make smdk2410_config 就是执行./mkconfig smdk2410 arm arm920t smdk2410 NULL s3c24x0
原因就是makefile中的
smdk2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
#mkconfig的作用:
1 BOARD_NAME=smdk2410
2建立链接
asm-arm<--asm
arch-s3c24x0<--asm-arm/arch
proc-armv<--asm-smdk2410/proc
3 创建include/config.mk
ARCH=arm
CPU=arm920t
BOARD=smdk2410
SOC=s3c24x0
4 创建include/config.h
/* Automatically generated - do not edit */
#include <configs/$1.h>
#确定开发板的名称BOARD_NAME
###############################################
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" #在BOARD_NAME不空的情况下,BOARD_NAME即为第一个参数 smdk2410
###############################################
#生成链接指向特定架构头文件
###############################################
if [ "$SRCTREE" != "$OBJTREE" ] ; then #判断源代码目录和目标目录是否一样
mkdir -p ${OBJTREE}/include
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 #使得asm链接到asm-arm
fi
###############################################
#
###############################################
if [ -z "$6" -o "$6" = "NULL" ] ; then #如果位置参数$6字符串长度为0或者为空NULL的话
ln -s ${LNPREFIX}arch-$3 asm-$2/arch #若LNPREFIX为空,等价于ln -s arch-$3 asm-$2/arch
else
ln -s ${LNPREFIX}arch-$6 asm-$2/arch #建立软链接:ln -s arch-s3c24x0 asm-arm/arch
fi
if [ "$2" = "arm" ] ; then
rm -f asm-$2/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi
###############################################
#为MAKE生成include文件,include/config.mk
###############################################
echo "ARCH = $2" > config.mk #将 “ARCH=arm“重定向到config.mk文件
echo "CPU = $3" >> config.mk #将"CPU=arm920t"追加到config.mk文件的尾部
echo "BOARD = $4" >> config.mk
[ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk
[ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk
###############################################
#创建开发板相关头文件 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