在调试 Exynos4412 的 u-boot 时,第一步就是 make smdk4412_config 这条命令,下面详细分析一下这条命令的处理流程。
该命令会从顶层目录中的 Makefile 开始执行:
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
%_config:: unconfig
@$(MKCONFIG) -A $(@:_config=)
- 首先命令在 Makefile 中匹配到对应的目标 %_config,其中 % 为通配符,表示任意字符
- 该目标的依赖为 unconfig,所以会执行 unconfig 对应的 rm 命令,删除一些自动生成的文件
- 然后在执行对应目标的命令,其中 @$(MKCONFIG) 为源码目录下的 mkconfig 文件, $(@:_config=) 属于变量的替换引用,将变量 $@ 中的 _config 替换为空,即 smdk4412_config 被替换为 smdk4412 ,最终该命令为 mkconfig -A smdk4412
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}
# add default board name if needed
[ $# = 3 ] && set ${line} ${1}
fi
#====================================&#