u-boot mkconfig文件分析

在编译u-boot之前先需要输入make 100ask24x0_config进行配置

 

在makefile文件中搜索 100ask24x0_config得到以下语句

100ask24x0_config	:	unconfig
	@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0

$(@:_config=)代表的意思是?

   其中@代表的是100ask24x0_config,那么$(@:_config=)就是将100ask24x0_config中的"_config"替换为空格

替换变量后得到

mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0

 

打开mkconfig ---脚本文件

100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0 相当于传入脚本文件的参数,$1为100ask24x0 之后为$2 以此类推

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

# $#代表脚本传入的参数个数 -gt代表大于等于
#如果输入参数个数大于等于0 执行循环
#根据第一个参数的内容分别进入对应的分支 #每运行一次shift 参数会左移一位 
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等于100ask24x0 
[ "${BOARD_NAME}" ] || BOARD_NAME="$1"

#如果输入参数个数小于4 或大于6退出
[ $# -lt 4 ] && exit 1
[ $# -gt 6 ] && exit 1

#打印字段
echo "Configuring for ${BOARD_NAME} board..."

#
# Create link to architecture specific headers
#如果SRCTREE不等于OBJTREE (在makefile中定义)
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  #进入include目录
	rm -f asm
 #创建一个链接文件asm指向asm-arm 
 #效果是如果源码内有#include <asm/type.h> 实际上是指向#include <asm-arm/type.h>
 #可以在不改源码的情况下 匹配各种板子
	ln -s asm-$2 asm
 
fi

rm -f asm-$2/arch

#如果第6个参数为空或NULL
if [ -z "$6" -o "$6" = "NULL" ] ; then
	ln -s ${LNPREFIX}arch-$3 asm-$2/arch
else
	ln -s ${LNPREFIX}arch-$6 asm-$2/arch #ln -s arch-s3c24x0 asm-arm/arch
fi

#如果第2个参数是arm
if [ "$2" = "arm" ] ; then
	rm -f asm-$2/proc
	ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi

#
# Create include file for Make
# 新建include/config.mk并输出一些信息
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

最后生成的/include/config,mk内容
ARCH   = arm
CPU    = arm920t
BOARD  = 100ask24x0
SOC    = s3c24x0

/include/config.h内容
/* Automatically generated - do not edit */
#include <configs/100ask24x0.h>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值