- 论坛徽章:
- 0
|
本帖最后由 uusky_cu 于 2012-01-18 22:17 编辑
脚本内容,当然只是头部的一部分,熟悉uboot的知道,这段就是uboot项目中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-2010 DENX Software Engineering, Wolfgang Denk <wd@denx.de>
- #
- APPEND=no # Default: Create new config file
- BOARD_NAME="" # Name to print in make output
- TARGETS=""
- arch=""
- cpu=""
- board=""
- vendor=""
- soc=""
- options=""
- if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then
- # Automatic mode
- line=`egrep -i "^[[:space:]]*${2}[[:space:]]" boards.cfg` || {
- echo "make: *** No rule to make target \`$2_config'. Stop." >&2
- exit 1
- }
- set ${line}#问题点1
- # add default board name if needed
- [ $# = 3 ] && set ${line} ${1}#问题点2
- fi
复制代码 其中boards.cfg文件内容如下:(部分)
- # Target ARCH CPU Board name Vendor SoC Options
- ###########################################################################################################
- qong arm arm1136 - davedenx mx31
- mx31ads arm arm1136 - freescale mx31
- imx31_litekit arm arm1136 - logicpd mx31
- mx35pdk arm arm1136 - freescale mx35
- omap2420h4 arm arm1136 - ti omap24xx
- tnetv107x_evm arm arm1176 tnetv107xevm ti tnetv107x
- armadillo arm arm720t
- ep7312 arm arm720t
- impa7 arm arm720t
- modnet50 arm arm720t
- lpc2292sodimm arm arm720t - - lpc2292
- SMN42 arm arm720t - siemens lpc2292
- evb4510 arm arm720t - - s3c4510b
- a320evb arm arm920t - faraday a320
- at91rm9200ek arm arm920t at91rm9200ek atmel at91 at91rm9200ek
- at91rm9200ek_ram arm arm920t at91rm9200ek atmel at91 at91rm9200ek:RAMBOOT
- eb_cpux9k2 arm arm920t - BuS at91
- cpuat91 arm arm920t cpuat91 eukrea at91 cpuat91
复制代码 问题点1:line的值,就是根据参数2 ${2}提供的target名字,搜索boards.cfg文件,找到一个匹配的行。我的疑问是,为啥需要set ${line},有啥作用呢?而且整个脚本内部,line变量出现了3次,全部在这段脚本里面。
问题点2:进入这个分支的条件之一就是$#等于2,为何又在该分支中判断[$# = 3]呢?这段代码岂不是永远执行不到?
还请shell达人给予指点,也请各位看官参与讨论!先谢过了。
|
|