u-boot的Makefile分析之一make smdk2410_config

在编译U-BOOT之前,先要执行

# make smdk2410_config

定义:

smdk2410_config : unconfig

 @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0

 

根据依赖关系,会先执行unconfig目标

定义:

unconfig:
 @rm -f $(obj)include/config.h $(obj)include/config.mk \
  $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
  $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep

注意不指定输出目标时,obj,src变量均为空,unconfig下面的命令清理上一次执行make *_config时生成的头文件和makefile的包含文件。主要是include/config.h 和include/config.mk文件

 

MKCONFIG 是顶层目录下的mkcofig脚本文件,后面五个是传入的参数

定义:

MKCONFIG := $(SRCTREE)/mkconfig
export MKCONFIG

执行:

 @$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0

$(@:_config=) :Target 

arm:Architecture 

arm920t :CPU 

smdk2410 :Board

samsung :VENDOR

s3c24x0:SOC

对于S3C2410和S3C2440,两种都被称为SOC(System on Chip),这上面除了CPU外,还集成了包括UART、USB控制器、Nand Flash控制器等设备(称为片内外设)。S3C2410的CPU为ARM920T。

$(@:_config=) 的结果就是将“smdk2410_config”中的“_config”去掉,结果为“smdk2410”。

所以“make smdk2410_config”实际上就是执行如下命令:

unconfig

./mkconfig smdk2410 arm arm920t smdk2410 samsung 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 <
[email protected]>
#

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"

[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1

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
echo "#include <configs/$1.h>" >>config.h
echo "#include <asm/config.h>" >>config.h

exit 0


 

执行./mkconfig smdk2410 arm arm920t smdk2410 samsung s3c24x0命令,假设执行

的是“./mkconfig $1 $2 $3 $4 $5 $6”,将产生如下结果。

  1. 开发板名称BOARD_NAME等于$1。
  2. 创建到平台/开发板相关的头文件的链接,如下所示:

   ln -s asm-$2 asm

   ln -s arch-$6 asm-$6/arch

   ln -s proc-armv asm-$2/proc

   3.  创建顶层Makefile包含的文件include/config.mk,如下所示:

  ARCH = $2

  CPU = $3

BOARD = $4

VENDOR =$5

SOC =$6

    4.  创建开发板相关的头文件include/config.h,如下所示:

/* Automatically generated - do not edit */
#include <configs/$1.h>

 

分析都这里,下回再续。。。。。

 

 

 

 

 

 

 

 

你可能感兴趣的:(u-boot的Makefile分析之一make smdk2410_config)