接下来看下一句话 [ "${BOARD_NAME}" ] || BOARD_NAME="$1" 这句话是说如果BOARD_NAME不为空,则BOARD_NAME等于$1,即“CCJ”。然后是 echo "Configuring for ${BOARD_NAME} board..." 这句话的含义就是打印“Configuring for CCJ board”,所以在我们执行“make CCJ_config”命令时,一定会打印出这句话来。其中CCJ是你开发板的型号。
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 fi rm -f asm-$2/arch
接着往下看,上面这段代码主要完成链接工作。首先if判断 $SRCTREE 是否等于 $OBJTREE,这里要注意了,这两个参数是我们在Makefile文件中定义的。看我发的第一个代码片中就有对它们的赋值。
OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) SRCTREE := $(CURDIR)
第一条语句的意思是如果我们定义了BUILD_DIR,则OBJTREE等于 $BUILD_DIR,否则等于 $CURDIR。那么这里我没有定义BUILD_DIR,所以OBJTREE= $CURDIR。所以现在OBJTREE=SRCTREE,则不执行if语句中的内容,而转去执行else分支的内容。
首先进入./include目录下,删除原来生成的asm文件,重新建立asm文件,并链接到asm-$2文件。经过前面的讲解,相信你已经知道asm-$2经过转换,得到asm-arm。也就是说现在asm->asm-arm。最后删除asm-arm/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
接着往下分析,如果$6不为空,或$6等于NULL,则执行if内的语句,我们$6=s3c24x0。所以执行分支语句,建立文件asm-am/arch,并指向arch-sac24x0。
第二个if中,因为$2等于arm,所以执行语句,删除asm-arm/proc,建立文件asm-arm/proc,并指向proc-armv。
# # 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 # # 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 exit 0
现在是不是有点累了?我们开始分析mkconfig的最后一大段^_^。坚持就是胜利!!!