Chinaunix首页 | 论坛 | 博客
  • 博客访问: 868292
  • 博文数量: 190
  • 博客积分: 7021
  • 博客等级: 少将
  • 技术积分: 1752
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-17 19:26
文章分类

全部博文(190)

文章存档

2014年(9)

2011年(32)

2010年(149)

我的朋友

分类: LINUX

2010-07-01 21:21:48

mini2440_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t mini2440 tekkamanninja s3c24x0

unconfig:
@rm -f $(obj)include/config.h $(obj)include/config.mk \
  $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp
其实这部分的功能就是删除一些文件

@$(MKCONFIG) $(@:_config=) arm arm920t mini2440 tekkamanninja s3c24x0
这部分$(@:_config)没看懂,后来在网上查到了一些高人的解释:

这里使用了Makefile中的替换引用规则,类似常看到的例子 obj=$(srcfiles:%.c=%.o): 由.c得到对应的.o文件.

这里是一样的道理:
 $(@:_config=)  
 
 @代表的是target mini2440_config, 那么$(@:_config=)就是将mini2440_config中的_config替换为空!得到mini2440; 你可以用echo自己打印出来看看就明白了!  

mini2440_config : unconfig
  @echo $(@:_config=) # 打印出来看看吧
  @$(MKCONFIG) $(@:_config=) arm arm920t mini2440 charming s3c24x0  

MKCONFIG其实就是根目录的脚本文件,这句的目的就是给脚本传递六个参数
所以上面的其实就是./mkconfig mini2440 arm arm920t mini2440 charming s3c24x0
现在来看看mkconfig的源代码,从而更深入了解其作用

#!/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 <wd@denx.de>
#

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

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


#第一个参数是mini2440,所以直接break不会有变化


[ "${BOARD_NAME}" ] || BOARD_NAME="$1"
#将板子的名字赋值为mini2440
[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1

if [ "${ARCH}" -a "${ARCH}" != "$2" ]; then
    echo "Failed: \$ARCH=${ARCH}, should be '$2' for ${BOARD_NAME}" 1>&2
    exit 1
fi

echo "Configuring for ${BOARD_NAME} board..."

#
# Create link to architecture specific headers
#
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 [ -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

#
# 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

for i in ${TARGETS} ; do
    echo "#define CONFIG_MK_${i} 1" >>config.h ;
done

echo "#include " >>config.h
echo "#include " >>config.h

exit 0

以上的脚本总结起来就是做了3件事:

在include文件夹下建立相应的文件(夹)软连接,

#如果是ARM体系将执行以下操作:
#ln -s     asm-arm        asm  

#ln -s  arch-s3c24x0    asm-arm/arch 
#ln -s   proc-armv       asm-arm/proc

生成Makefile包含文件include/config.mk,内容很简单,定义了四个变量:

ARCH   = arm
CPU    = arm920t
BOARD  = mini2440

VENDOR = tekkamanninja
SOC    = s3c24x0

生成include/config.h头文件,只有两行:

/* Automatically generated - do not edit */
#include "configs/mini2440.h"

#include"asm/config.h"

阅读(4151) | 评论(0) | 转发(3) |
0

上一篇:mini2440

下一篇:u-boot.lds和vivi.lds文件分析

给主人留下些什么吧!~~